When exactly are javascripts parsed and interpreted? -
this question has answer here:
- load , execute order of scripts 3 answers
please feel free close question if duplicate(i not find question answers this.)
experts recommend place javascript files @ bottom of body tag(or before when necessary). makes sure other elements of page(like css, images, etc) not blocked due javascript file.
my understanding browser, opens connections downloading resources. downloads javascript file in same way downloads other resource. once understands javascript file(by looking @ type), starts new thread(parser) , gives file thread parsing , interpretation. , continues download other files. if script encountered, queued on created thread. understanding correct? or browser starts parsing on same thread on script file downloaded , subsequent downloads on thread blocked until parsing complete?
what happens when javascript files comes browser cache? behaviour different?
i hope answers true browsers(ie, chrome, ff)
the reasoning behind putting javascript in footer not interfere html data being created on page. if need include javascript file contains functions, include in header without issues, it's more code uses these functions need worry about.
<head> <script type="text/javascript>...</script> <script type="text/javascript>...</script> ... </head> <body> <p>some html here ... </p> ... <script type="text/javascript"> here goes slow, time consuming script may call scripts above. </script> </body>
Comments
Post a Comment