I was learning about appendChild and have so far come up with this code:
appendChild
I believe you can just link your JavaScript to your html using the defer attribute.
This way your JavaScript will not run until after the page has loaded.