Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do external javascript references cause the browser to wait until they are downloaded?

When your page is being parsed, and it comes across a <script src='someExternalSite/jquery.js'></script> or whatever, does the page wait until that file is downloaded and available before continuing to parse?

Added:

Do most browsers simultaneously download all the scripts to save time (even if they execute them in order)?

like image 704
NibblyPig Avatar asked Dec 01 '10 11:12

NibblyPig


2 Answers

each tag blocks the page from further rendering until the js file fully downloaded. Its a good idea to place js file in end of body tag

like image 190
Amit Singh Avatar answered Sep 18 '22 00:09

Amit Singh


does the page wait until that file is downloaded and available before continuing to parse?

Not only does it wait until the JS has been downloaded, it waits until it has been parsed and executed. The others advice about putting it at the end of page is spot on.

Do most browsers simultaneously download all the scripts to save time (even if they execute them in order)?

Actually, I think only the newer ones do. I came across a webpage about this ages ago that I didn't bookmark, sorry.

like image 26
James Avatar answered Sep 20 '22 00:09

James