Loading scripts at the end
The heart of any application lives in the JavaScript files that are defined by the developers. Hence, we will need to pay extra attention while we try to load and execute these files, which can be significantly larger than that of their counterpart HTML and CSS files. When we try to load external JS files using a script tag, the browser first downloads them and then executes them (after parsing and compiling). We will need to make sure that our application is loaded and executed at the right time. What that means for us is that if our application logic is reliant on the DOM, we need to ensure that the DOM is rendered before the script is executed. This makes it a pretty good reason for us to load the scripts at ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access