-
The HTML grammar definition (HTML DTD)
-
DOM, The output tree - the "parse tree" is a tree of DOM element and attribute nodes. Document Object Model
-
The parsing algorithm
- consists of two stages - tokenization and tree construction.
- state machine
- Tree construction algorithm: "insertion modes"
-
when the parsing is finished
- mark the document as interactive
- start parsing scripts that are in "deferred" mode - those who should be executed after the document is parsed. The document state will be then set to "complete" and a "load" event will be fired.
- Script
- scripts to be parsed and executed immediately when the parser reaches a
<script>
tag. - The parsing of the document halts until the script was executed.
- If the script is external then the resource must be first fetched from the network. this is also done synchronously
- scripts to be parsed and executed immediately when the parser reaches a
- Speculative parsing
- Style sheets
- Firefox blocks all scripts when there is a style sheet that is still being loaded and parsed. Webkit blocks scripts only when they try to access certain style properties that may be effected by unloaded style sheets.
- Further work Style Computation
- The rendering engine is single threaded.
- Network operations can be performed by several parallel threads
- 1 js + 2 CSS + 2 imagse (DomContentLoad early !!)
- 2 CSS + 2 images + 1 js
- http://www.stevesouders.com/blog/2012/10/09/webperfdays-performance-tools/
- http://ablogaboutcode.com/2011/06/14/how-javascript-loading-works-domcontentloaded-and-onload/
- https://developer.mozilla.org/en-US/docs/DOM/DOM_event_reference/DOMContentLoaded
- The DOMContentLoaded event is fired at the page's document object when parsing of the document is finished. By the time this event fires, the page's DOM is ready, but the referenced stylesheets, images, and subframes may not be done loading; use the "load" event to detect a fully-loaded page.