perf: omit app-webrtc.js from page load when WebRTC is disabled#552
Closed
sam-saffron-jarvis wants to merge 1 commit intoSamSaffron:mainfrom
Closed
perf: omit app-webrtc.js from page load when WebRTC is disabled#552sam-saffron-jarvis wants to merge 1 commit intoSamSaffron:mainfrom
sam-saffron-jarvis wants to merge 1 commit intoSamSaffron:mainfrom
Conversation
app-webrtc.js (21 KB uncompressed, ~6 KB gzip) is an IIFE that only activates when window.__WEBRTC_ENABLED__ is set. Without that flag the entire script is dead code — it is parsed and executed but does nothing. When webrtcHeadSnippet is empty (the default for all non-WebRTC deployments): - strip the <script src="app-webrtc.js"> tag from the rendered HTML - remove the './app-webrtc.js?v=...' entry from the service worker's SHELL_ASSETS list so the SW does not precache the file on install WebRTC-enabled deployments are unaffected: the script tag is kept and the service worker still precaches the asset. Adds unit tests for the two helpers and integration tests through renderIndexHTML() confirming the tag is present/absent as expected.
Owner
|
Closed in favor of a cleaner implementation that avoids parsing rendered HTML/JS and uses explicit serveui render options/placeholders instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Omit
app-webrtc.jsfrom the page and service worker when WebRTC is not enabled.<script src="app-webrtc.js?v=...">tag from the renderedindex.html'./app-webrtc.js?v=...'from the service worker'sSHELL_ASSETSlistWebRTC-enabled deployments (
--webrtcflag /TERM_LLM_WEBRTC_*env) are unaffected — the script tag is preserved and the SW still precaches the asset.Why
app-webrtc.jsis 21 KB uncompressed (~6 KB gzip). It is an IIFE that checkswindow.__WEBRTC_ENABLED__at startup and exits immediately when the flag is absent. Without the flag the entire file is dead code: the browser fetches it, parses it, executes it — and nothing happens.For the vast majority of deployments (no
--webrtcflag), this saves:Tests
TestRenderIndexHTML_DropsWebRTCScriptWhenDisabled— script tag absent whenwebrtcHeadSnippetis emptyTestRenderIndexHTML_KeepsWebRTCScriptWhenEnabled— script tag present when snippet is setTestDropScriptTagContaining— helper removes correct tag, leaves othersTestDropScriptTagContaining_NeedleAbsent— no-op when needle not foundTestDropSWShellAssetContaining— removes webrtc entry from real rendered SW, other assets intact