2

I'm willing to use HTTP/2.0 on my apache server. I'm using apache over HTTP/1.1 and I have structured my site like this :

<head>
sharedJS.js
1.js
2.js

sharedCSS.css
1.css
2.css
</head>

Where 1,2 files have dependencies in the shared ones. In HTTP/1.1 are loaded and executed in the order of declaration. With HTTP/2.0 they are requested/loaded simultaneously but what about execution? First loaded first served? What happens if one of the 1.css/js is loaded before the relative sharedCSS/JS? Is the execution order preserved? Or I have to restructure my whole site ?

  • Even in HTTP/1.1 you could have everything loaded from cache, which would make it all available simultaneously. – Stephen Ostermiller Feb 9 at 13:19
  • Hmm ok, know I miss that answer too. Maybe it is related to the different "download" speed ? (cache reading/internet download). Thanks for your edit anyway! – M_Ta Feb 9 at 18:15
2

No. Because the browser waits until the HTML is loaded before parsing it. Once it parses the HTML, it then reads the CSS and HTML files. Browsers never concern themselves with order of downloading.

  • What do you mean with "waits until the HTML is loaded"? Because for example : In my head tag I have an example.js . In my example.js I try to bind an event to an html element. It will fail, unless I wait for the DOM ready (eg : document.ready() ). So the code is executed when it is parsed/downloaded/executed. Maybe I'm messing up different things – M_Ta Feb 9 at 18:12
  • @M_Ta Perhaps I confused the issue by saying it that way. What I mean is, the order of downloading by parallel in H/2 will not affect how the browser handles those files because it is the order in the HTML that matters. – Rob Feb 9 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.