eidellev / inertiajs-adonisjs

280 stars 17 forks source link

make sure "app.edge" template load js script properly #89

Closed albasyir closed 1 year ago

albasyir commented 1 year ago

Tested on fresh install adonisjs and inertiajs-adonisjs, compiled js isn't load properly

The script tag should always be used before the body closes or at the bottom of the HTML file. The Page will load with HTML and CSS and later JavaScript will load.

Placing scripts at the bottom of the element improves the display speed, because script interpretation slows down the display.

ref:

eidellev commented 1 year ago

Hey @albasyir ! Thank you for opening this PR. I really appreciate it 🙏 However there is no need for this change. If you look at the HTML that's being generated you'll notice that the script tag has a defer attribute which solves the problem.

image

https://www.w3schools.com/tags/att_script_defer.asp

Let me know if you have any additional questions

P.S. if you need to support older browsers that don't support defer you may need to move the script tag to the bottom of the page, but for modern browsers there's really no need