# Programming Elm: need to wait for DOMContentLoaded to getElementById?

**URL:** <https://forum.devtalk.com/t/programming-elm-need-to-wait-for-domcontentloaded-to-getelementbyid/1290>\
**Category:** PragProg Customers\
**Tags:** book-programming-elm, suggestion\
**Created:** [9 August 2020 06:16 UTC](https://forum.devtalk.com/t/programming-elm-need-to-wait-for-domcontentloaded-to-getelementbyid/1290 "2020-08-09T06:16:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jfairbank](https://forum.devtalk.com/user_avatar/forum.devtalk.com/jfairbank/32/1084_2.png) [@jfairbank](https://forum.devtalk.com/u/jfairbank)\
**Post date:** [23 September 2020 05:44 UTC](https://forum.devtalk.com/t/programming-elm-need-to-wait-for-domcontentloaded-to-getelementbyid/1290/2 "2020-09-23T05:44:53Z")

</div>

Hi, @gcapell!

Thanks for the question and sorry for missing your question so long ago. We’ve been transitioning over with the new Prag site changes to these forums.

You can definitely place the `script` tags in the `head` if you like and then use the `DOMContentLoaded` event to kick off the initialization as you’ve already done.

The intent in the book was to place the `script` before the closing `</body>` tag, replacing the `<!-- REPLACE ME -->` comment. As long as the script tags are below the `<div id="main">` tag, you don’t need the `DOMContentLoaded` event as that element will be available by that point. I can see how the book could be misleading, though, since it doesn’t explicitly say to put the scripts in the `body`.

Sorry for the confusion and glad you had figured out a way to fix it with the event.

Cheers!

---

_[View the full topic](https://forum.devtalk.com/t/programming-elm-need-to-wait-for-domcontentloaded-to-getelementbyid/1290)._
