Reputation: 29
I'm studying JavaScript, but I wanna do it very well...
I readed some questions, here in StackOverflow, but seems they don't fix my issue.
I tried an example with an external script in Google Chrome v. 31.0.1650.57:
I put the script
element at the bottom (before the </body>
tag with the next code:
Code JS:
for(var i = 0; i < 100000000; i++)
Here's the HTML:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<h2>Logo</h2>
</header>
<script src="js/code.js"></script>
</body>
</html>
It supposed to be that the content shows to me and later, the script will be downloaded, parsed and executed. BUT that wasn't what happened! The content of the page shows to me only when the script was downloaded and executed (I think that, because it took a lot of time).
So, what really happened?
Is it the author wrong? Or did I do something wrong?
Upvotes: 1
Views: 70
Reputation: 33809
As per your suggestion, I am repeating my comment as an answer here.
Reason could be your loop is blocking the UI thread. Here are some more details on this blog post, What is a non-blocking script?
Upvotes: 2