How does a browser go about parsing JavaScript it loads from files or inline? I am trying to get at the core of what a browser does. What happens when a page loads and it has <script> references to external files, and actual JavaScript on the page too. Any good articles out there?
How does a browser go about parsing JavaScript it loads from files or inline?
Share
This is defined in the ECMAScript standard.
First the source text (the stuff between the
<script>tags) is converted into a series of tokens (according to the Lexical Grammar of the language):Read here: http://es5.github.com/#x7
That series of tokens is treated as a Program, which is then evaluated according to the Syntactic Grammar of the language which is defined in chapters 11 to 14 of the ECMAScript standard.
Read here: http://es5.github.com/#x5.1.4
It starts in chapter 14: http://es5.github.com/#x14
Note that each
<script>element represents a separate JavaScript program.Read here: How many JavaScript programs are executed for a single web-page in the browser?