When a resonant cavity is perturbed, e.g. by introducing a foreign object with distinct material properties into the cavity or when the shape of the cavity is changed slightly, electromagnetic fields inside the cavity change accordingly. This means that all the resonant modes (i.e. the quasinormal mode) of the unperturbed cavity slightly change. Analytically predicting how the perturbation changes the optical response is a classical problem in electromagnetics, with important implications spanning from the radio-frequency domain to present-day nano-optics. The underlying assumption of cavity perturbation theory is that electromagnetic fields inside the cavity after the change differ by a very small amount from the fields before the change. Then Maxwell's equations for original and perturbed cavities can be used to derive analytical expressions for the resulting resonant frequency shift and linewidth change (or Q factor change) by referring only to the original unperturbed mode (not the perturbed one).