# Order of a holomorphic function along an analytic hypersurface

Let $Y\subset \mathbb{C}^n$ be an analytic subset, i.e. for every $x \in Y$ there exists a holomorphic function (germ) $g \in \mathcal{O}_x$ such that $Y$ is locally cut out by $x$. Let $f$ be a holomorphic function, and suppose that $Y$ is locally cut out by irreducible $g\in \mathcal{O}_x$ around $x$, then the order of $f$ at $x \in Y$ is defined to be the integer $a=ord_x f$ such that $f=g^a h$ in the factorization of $\mathcal{O}_x$ (since $\mathcal{O}_x$ is a UFD).

It is claimed, in many complex geometry books like Huybrechts and Griffiths, that $ord_x f$ is locally constant, yet I don't see why this is true. I suppose a proof would be along the lines of:

$Y$ at a point $y$ near $x$ is also locally cut out by $g\in \mathcal{O}_y$, and $h$ remains to be relatively prime to $g$ if $y$ is close enough, so we still have $f=g^{ord_x f} h$ in $\mathcal{O}_y$.

But my problem with the above proof is that $g$ may not be a locally defining function of $Y$ at $y$, in particular $g$ could be reducible in $\mathcal{O}_y$, since there are examples of irreducible holomorphic function germs becoming reducible in a neighborhood (see: Irreducibility of holomorphic functions in a neighborhood of a point). In this case we can only conclude $ord_y f \geq ord_x f$, i.e. the order is locally non-decreasing.

An explanation of how to reason that the order is locally constant would be great. Thank you.