diff --git a/README.md b/README.md index 38bf95b..6bd5551 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,14 @@ feedback on the proposed solution. It has not been approved to ship in Chrome. This proposal introduces a new magic comment that signals to browsers that the functions in a JavaScript file are likely to be needed by the website. This allows the browser to parse and compile them eagerly, which can improve page load times. +In this example, the magic comment is used for triggering the eager compilation of the two JavaScript functions in the file: +```JavaScript +//# eagerCompilation=all + +function foo() { ... } // will now be eagerly parsed and compiled +function bar() { ... } // will now be eagerly parsed and compiled +``` + ### On JavaScript parsing and compilation Knowing which JavaScript functions to parse and compile during the initial script compilation can speed up web page loading. @@ -90,9 +98,6 @@ We propse adding the following magic comment to trigger eager compilation of all ```JavaScript //# eagerCompilation=all - -function foo() { ... } // will now be eagerly parsed and compiled -function bar() { ... } // will now be eagerly parsed and compiled ``` The magic comment is intended as a hint to the browser. It signals the functions in this JS file should be treated as "high priority" - for example, compile them immediately when processing the script, as opposed to when a function is called.