# Window.onload event not firing

**URL:** https://forum.8thwall.com/t/window-onload-event-not-firing/209
**Category:** Technical Support
**Created:** [February 7, 2024, 10:27pm UTC](https://forum.8thwall.com/t/window-onload-event-not-firing/209 "2024-02-07T22:27:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Evan](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/evan/32/431_2.png) [@Evan](https://forum.8thwall.com/u/Evan)
#### Post date: [February 7, 2024, 10:27pm UTC](https://forum.8thwall.com/t/window-onload-event-not-firing/209/1 "2024-02-07T22:27:14Z")

</div>

The window.onload event is not firing in my 8th Wall hosted project. How do I listen for the onload event in 8th Wall?

---

<div class="post-metadata">

### Author: ![TonyT](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/tonyt/32/88_2.png) [@TonyT](https://forum.8thwall.com/u/TonyT)
#### Post date: [February 7, 2024, 11:30pm UTC](https://forum.8thwall.com/t/window-onload-event-not-firing/209/2 "2024-02-07T23:30:30Z")

</div>

The loading sequence of cloud editor projects is `head.html` \> `app.js` \> `body.html` . By the time your code in `app.js` is executed, the `onload` event has likely already fired (while the default splash screen is being displayed).

A better/safer approach is to listen on events such as [realityready](https://www.8thwall.com/docs/api/aframeevents/realityready/) (AFrame) or [xrloaded](https://www.8thwall.com/docs/api/xr8/#events) events (when XR8 is on the window), or within init() of an AFrame component.

---

<div class="post-metadata">

### Author: ![Erik\_Murphy-Chutoria](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/erik_murphy-chutoria/32/66_2.png) [@Erik\_Murphy-Chutoria](https://forum.8thwall.com/u/Erik_Murphy-Chutoria)
#### Post date: [February 16, 2024, 12:55am UTC](https://forum.8thwall.com/t/window-onload-event-not-firing/209/3 "2024-02-16T00:55:02Z")

</div>

If you wish to make DOM manipulations programmatically after `body.html` is loaded, a common pattern is to put code similar to the following at the end of `app.js`:

```auto
const onxrloaded = () => {
  // Run any code that you'd like to execute after the body.html is loaded.
}

window.XR8 ? onxrloaded() : window.addEventListener('xrloaded', onxrloaded)

```
