Last post Jun 28, 2019 09:33 AM by PatriceSc
Jun 26, 2019 05:42 PM|jsshivalik|LINK
Where Script tag should be written . What is the advantage of writing before form. What happens if it is written in Head tag
Jun 26, 2019 05:47 PM|mgebhard|LINK
What is the advantage of writing before form.
None really, Modern patterns add script tags to the bottom of the page.
What happens if it is written in Head tag
You'll need to wrap any element handlers in a ready event or function otherwise the the HTML element will not exist when the script loads.
Jun 28, 2019 09:33 AM|PatriceSc|LINK
Historically, the idea was likely to define all what the page depends on at the top. But as scripting became widespread and more complex it caused a delay (loading, parsing, running js code) in rendering the page so the pattern is now rather to place scripts
at the end so that the HTML/CSS can processed and rendered first.
BTW we have now a defer attribute on script tags which should have the same effect that moving the script down (but having scripts at the end is now an habbit).