I have some JavaScript code that I'd like to load only once the page scrolls to a certain id tag.
For example, imagine I have a script model.js and an html element
<p id='anchor'></p>.
My goal is to trigger the load of <script src="model.js"></script> at the point when the page reaches the <p id='anchor'></p>
I'm assuming there's a fairly trivial way to achieve this, but I'm having difficulty finding how how to do so. So far my research only yielded stuff using defer or async in the <script> load, but those don't seem to give me the results I want.
Any help is greatly appreciated!