# JS nach DOM-Laden ausführen

**URL:** <https://meta.discourse.org/t/executing-js-after-dom-loaded/102958>\
**Category:** Product Support\
**Created:** [28. November 2018 um 09:03 UTC](https://meta.discourse.org/t/executing-js-after-dom-loaded/102958 "2018-11-28T09:03:55Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![marina](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@marina](https://meta.discourse.org/u/marina)\
**Post date:** [28. November 2018 um 09:03 UTC](https://meta.discourse.org/t/executing-js-after-dom-loaded/102958/1 "2018-11-28T09:03:55Z")

</div>

Hi,

I would like to run a script that appends HTML code to a specific element within the HTML’s body on page change. However, this is not working. It only works after refreshing the page.

After doing some research, I believe it is due to the script being executed after the page has changed (I currently use “api.onPageChange(() =\>{}” to handle this) but BEFORE the DOM has fully loaded. As the DOM has not fully loaded, my script is unable to find the specific element to append the HTML code to.

Could any experts here provide me with some tips or work-around? 😁

Marina

---

_[View the full topic](https://meta.discourse.org/t/executing-js-after-dom-loaded/102958)._
