-1

In JavaScript, HTML and CSS, what is the sequence in which these are loaded in a browser?

And also, is there any important reason for using that sequence?

Heretic Monkey
  • 11,078
  • 7
  • 55
  • 112
  • This might be of assistance: https://stackoverflow.com/questions/1795438/load-and-execution-sequence-of-a-web-page/1795502#1795502 – imvain2 May 15 '20 at 19:37
  • 2
    Well, think about it this way; does HTML have references to JavaScript and CSS, or does CSS have references to JavaScript and HTML, or does JavaScript have references to HTML and CSS? That last one has certainly clouded this issue somewhat in recent years, but simply looking at the network tools of your browser when you make a request to a web site would show which one comes first. – Heretic Monkey May 15 '20 at 19:40
  • Yes. Also, yes. – NVRM May 15 '20 at 19:42

1 Answers1

1

I believe loading is primarily asynchronous; so stylesheets may load asynchronously, like images, while the rest of the page is being read & loaded. When a script tag is encountered, it is loaded entirely and executed before moving forward to execute another script tag but some browsers have the capability to look forward to the existence of additional script tags and download the scripts while other scripts are loading or executing in order. This is probably not an authoritative answer but it can point you in the direction. There are likely to be other good posts on this, such as Sequence in which HTML page loads?

Cheers, Kylie

Kylie R.
  • 94
  • 6