We study the optical properties of the Ruddlesden-Popper series of iridates Sr$_{n+1}$Ir$_n$O$_{3n+1}$ ($n$=1, 2 and $infty$) by solving the Bethe-Salpeter equation (BSE), where the quasiparticle (QP) energies and screened interactions $W$ are obtained by the $GW$ approximation including spin-orbit coupling. The computed optical conductivity spectra show strong excitonic effects and reproduce very well the experimentally observed double-peak structure, in particular for the spin-orbital Mott insulators Sr$_2$IrO$_4$ and Sr$_3$Ir$_2$O$_7$. However, $GW$ does not account well for the correlated metallic state of SrIrO$_3$ owing to a much too small band renormalization, and this affects the overall quality of the optical conductivity. Our analysis describes well the progressive redshift of the main optical peaks as a function of dimensionality ($n$), which is correlated with the gradual decrease of the electronic correlation (quantified by the constrained random phase approximation) towards the metallic $n=infty$ limit. We have also assessed the quality of a computationally cheaper BSE approach that is based on a model dielectric function and conducted on top of DFT+$U$ one-electron energies. Unfortunately, this model BSE approach does not accurately reproduce the outcome of the full $GW$+BSE method and leads to larger deviations to the measured spectra.