Proving that an inverse ring homomorphism of an ideal is an ideal?

Say I have some function $$f:R \rightarrow S$$ such that $$f$$ is a ring homomorphism and $$J$$ is an ideal of $$f$$. $$I = f^{-1}(J)$$ is an ideal of $$R$$, but I don't really understand why. $$J$$ being an ideal means that $$I$$ is non-empty, that much makes sense.

But how can I show that addition/absorption hold if $$f$$ isn't surjective, nor do I know if $$f^{-1}$$ is even a ring homomorphism? I've seen a very similar question has been asked, but the only response appeared to just prove that these things held in $$J$$.

For instance, if I want to prove addition holds, I could take $$i_1, i_2 \in I$$ so that for $$j_1, j_2 \in J$$, $$i_1 = f^{-1}(j_1)$$, $$i_2 = f^{-1}(j_2)$$. But then I can't really add these elements together because I don't know if addition is preserved in $$f^{-1}$$. What gives?

The definition of $$f^{-1}(J)$$ is $$\{r\in R: f(r) \in J\}$$. If $$i_1,i_2 \in f^{-1}(J)$$ the $$f(i_1)$$ and $$f(i_2) \in J$$ so $$f(i_1+i_2)=f(i_1)+f(i_2) \in J$$ which implies $$i_1+i_2 \in f^{-1} (J)$$. It is not assumed that $$f$$ is a bijection so you cannot think of $$f^{-1}$$ as a function from $$S$$ into $$R$$. You have to use definition of inverse image of a set: $$f^{-1}(J)=\{r\in R: f(r) \in J\}$$. Now you should be able to complete the rest of the proof.

Suppose $$x,y\in f^{-1}(J)$$.

Then $$f(x),f(y)\in J$$ so $$f(x)-f(y)=f(x-y)\in J$$.

So $$x-y\in f^{-1}(J)$$.

If $$a\in R, x\in f^{-1}(J)$$.

Then $$f(ax)=f(a)f(x) \in J$$, since $$f(a)\in S$$ and $$f(x)\in J$$.

So $$ax\in f^{-1}(J)$$, and similarly for the reverse multiplication