# Index.html error about scripts, but I have to have a script load after the body for my code to work?!

**URL:** https://forum.pinegrow.com/t/index-html-error-about-scripts-but-i-have-to-have-a-script-load-after-the-body-for-my-code-to-work/11407
**Category:** Beginners
**Created:** [February 15, 2026, 12:00am UTC](https://forum.pinegrow.com/t/index-html-error-about-scripts-but-i-have-to-have-a-script-load-after-the-body-for-my-code-to-work/11407 "2026-02-15T00:00:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![TEMPEST](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/tempest/32/6851_2.png) [@TEMPEST](https://forum.pinegrow.com/u/TEMPEST)
#### Post date: [February 15, 2026, 12:00am UTC](https://forum.pinegrow.com/t/index-html-error-about-scripts-but-i-have-to-have-a-script-load-after-the-body-for-my-code-to-work/11407/1 "2026-02-15T00:00:16Z")

</div>

I’m trying to build my first Component (a nav bar). I have custom html/css for a hamburger menu and a shopping cart and then the site logo in the middle.

In order for the menu and shopping cart to work I created some js which is saved in it’s own file.

However, in order for this code to work, I **must** place the script load line **after** the closing body html tag:

```auto
    </body>

    <script src="assets/js/aiboetc.js"></script>     

</html>

```

but when I do this and next reload the project I get an error warning.

 ![Screenshot 2026-02-14 at 23.38.14](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/1/187818c2b45016d23ba23f89364820396c5fde6b.png)

The warning goes away if I put the script load in the **head** tag, but then my code doesn’t work.

Could someone please tell me where I’ve gone wrong?

Thanks.

---

<div class="post-metadata">

### Author: ![TEMPEST](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/tempest/32/6851_2.png) [@TEMPEST](https://forum.pinegrow.com/u/TEMPEST)
#### Post date: [February 15, 2026, 12:14am UTC](https://forum.pinegrow.com/t/index-html-error-about-scripts-but-i-have-to-have-a-script-load-after-the-body-for-my-code-to-work/11407/2 "2026-02-15T00:14:32Z")

</div>

Sorry, I think I’ve fixed it: [How To Defer JavaScript On Your Website | DebugBear](https://www.debugbear.com/docs/how-to-defer-javascript-on-your-website#:~:text=Add%20the%20defer%20attribute%20to,multiple%20deferred%20scripts%20are%20used).

Needed to add ‘defer’ to the end of the script line when in the ‘head’ section.

---

<div class="post-metadata">

### Author: ![Emmanuel](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/emmanuel/32/6294_2.png) [@Emmanuel](https://forum.pinegrow.com/u/Emmanuel)
#### Post date: [February 17, 2026, 1:41pm UTC](https://forum.pinegrow.com/t/index-html-error-about-scripts-but-i-have-to-have-a-script-load-after-the-body-for-my-code-to-work/11407/3 "2026-02-17T13:41:26Z")

</div>


