js-profiling-mode=eager|lazy Document-Policy for JS Self-Profiling API
- Category
- Performance
- Type
- New or changed feature
- Status
- Proposed (Chrome Proposed)
- Intent stage
- None
WPT details: https://wpt.fyi/results/js-self-profiling/js-profiling-mode
Summary
Introduces a new Document-Policy value "js-profiling-mode=eager|lazy". Setting "js-profiling-mode=lazy" authorizes JS Self-Profiling capability without incurring immediate initialization overhead during page load. Related WICG PR : https://github.com/WICG/js-self-profiling/pull/87 Related discussion for more context: https://github.com/WICG/js-self-profiling/issues/86
Motivation
There are several pain points with the current “eager” approach: 1 - Performance trade-offs between loading and profiling There is no way to defer profiling overhead to a non-critical period (e.g., after page load). There is no way to incur overhead only if the Profiling API is actually used. Many users are unwilling to trade page load performance for profiling capabilities. 2 - Sampling strategy coupling between backend (server) and frontend (client) To avoid overhead on unsampled sessions, sampling must be aligned between server and client, which introduces operational complexity. In many setups, sampling occurs on the client side; keeping server and client in sync requires additional tooling. Even if a session is not sampled, the presence of the header means the page still pays the warm-up cost. (See https://github.com/WICG/js-self-profiling/issues/86 for full context)
Standards & signals
- Specification: https://wicg.github.io/js-self-profiling/#js-profiling-mode
- Firefox: No signal
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://issues.chromium.org/issues/473861788?pli=1
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=js-self-profiling%2Fjs-profiling-mode
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+js-profiling-mode%3Deager%7Clazy%20Document-Policy%20for%20JS%20Self-Profiling%20API
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=js-profiling-mode%3Deager%7Clazy%20Document-Policy%20for%20JS%20Self-Profiling%20API
- Baseline status: https://webstatus.dev/?q=js-profiling-mode%3Deager%7Clazy%20Document-Policy%20for%20JS%20Self-Profiling%20API
Docs: https://github.com/WICG/js-self-profiling/issues/86 https://wicg.github.io/js-self-profiling/#js-profiling-mode
Explainers: https://github.com/WICG/js-self-profiling/issues/86