embed-page
embed-page copied to clipboard
Load performance optimizations
Current implementation in most heavy demo page delays the full page load for 1.1 second which is too long accounting the basic nature of scripts used for demo. It also does not survive default timeout when runs under debugger in FF.
CAUSE There are several fundamental issues of current embed-page implementation:
- scripts loaded, parsed, wrapped, and loaded within page thread. Causing causing heavy CPU use in UX thread.
- scripts are executed as modules and UX is disabled till all scripts done.
- wrappers do marshalling globals to and from window object for all keywords in epa page while only global variables need to be in sync with window object. The const and functions need to be saved to window object only upon initialization.
Solutions
- load, parsing, wrapping to be done in separate thread( worker, frame, etc tbd)
- execution sequence of epa scripts by browser need to be replaced with controlled prioritized execution queue. Letting enough cycles for page to be responsive.
- parsing by regex searches for all variables to be replaced by AST traverse exposing global level vars, constants, functions. To speed up parsing the comments and curly braces scopes could be cleared.
- wrapping would load window object values only to global var variables; functions saved to window in beginning of script; const and var saved to window in the end of script. Q. How to define whether CPU in main js thread is available?