An SVG and JS, right? It's not interactive on its own.
The JS is embedded within the SVG file and not exposed outside it
The JS is exposed in the full page's context the same as if you included a <script> under a <div> instead of <svg>. In much the same way, whether the <script> is before or after the <svg> tag doesn't matter - it's just a script working on a single DOM (with different namespaces for certain elements) either way.