demo · v132
Lazy vs eager parsing, side-by-side
When you call a function the engine has to do three things: parse, compile, execute. Without hints, V8 lazy-parses every function and re-parses on first call. The magic comment //#allFunctionsCalledOnLoad opts the file into eager compilation. Simulate which functions get called and watch the trade-off.
lazy (default)
no hint — every called fn is re-parsed at first call
script eval—
tti contribution—
eager (magic comment)
//#allFunctionsCalledOnLoad — everything parsed up-front
script eval—
tti contribution—
parse
compile
execute
your bundler annotation
// at top of bundle.js
//#allFunctionsCalledOnLoad
function init() { ... }
function renderLayout() { ... }
function attachEventHandlers() { ... }
// V8 eagerly parses and compiles all three immediately