JS script renders at bottom of page and not in specific location

I have a simple JS script that i want to render inside an <article><div> on an infinite scroll page in WordPress. The script loads, but it renders the script/text all the way at the bottom of the page (under footer).

How do I load the script/text directly in the <article><div>?

<article><div><script type="text/javascript" src="text1.js"></script></div></article>

the script text1.js:

document.body.appendChild(document.createElement('div'))
  .textContent = 'Hello!';