You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Usually it is recommended to place the <script> tags right before closing the body tag (</body>) so that the browser's parser doesn't get blocked until all the JavaScript is downloaded. Wouldn't it be better to place the <script> tag at the bottom of the body of index.html?
<!DOCTYPE html><htmlng-app="<%=appName%>" ng-controller="AppController"><head><titleng-bind="pageTitle"></title><!-- font awesome from BootstrapCDN --><linkhref="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"><!-- compiled CSS --><% styles.forEach( function ( file ) { %><linkrel="stylesheet" type="text/css" href="<%= file %>" /><% }); %></head><body><header><navclass="container navbar-default"><ulclass="nav navbar-nav"><liui-sref-active="active"><aui-sref="home">Home</a></li><liui-sref-active="active"><aui-sref="about">About</a></li></ul></nav></header><divclass="container" ui-view="main"></div><footerclass="container">
(c) <%= date %><%= author %></footer><!-- compiled JavaScript --><% scripts.forEach( function ( file ) { %><scripttype="text/javascript" src="<%= file %>"></script><% }); %></body></html>
The text was updated successfully, but these errors were encountered:
blizarazu
changed the title
Why not load JavaScript in the body?
Wouldn't it be better to load JavaScript in the body?
Feb 7, 2016
That practice is generally good for pages that use javascript to provide some small effects to the page itself, but still need to load very quickly. When you're talking about a SPA, you're usually dealing with a web application, and having the application fully loaded and responsive is usually more valuable than having the first page load quickly.
My advice is to use static html for your landing pages, marketing site, SEO-friendly, lead-generation websites, and use a SPA for your web applications. On the former, speed is paramount on the first hit. On the latter, functionality is the top priority, and we can settle for speed after the first hit. Having everything loaded and ready to go once the user starts clicking is more important. Once we get some traction on javascript loaders/managers in the browser, we'll start thinking about a hybrid approach, but I haven't needed to merge the two yet. I usually go one route or the other.
Usually it is recommended to place the
<script>
tags right before closing the body tag (</body>
) so that the browser's parser doesn't get blocked until all the JavaScript is downloaded. Wouldn't it be better to place the<script>
tag at the bottom of the body of index.html?The text was updated successfully, but these errors were encountered: