Serve minified static assets and stop blocking HTML parsing - #13
Open
mamico wants to merge 2 commits into
Open
Conversation
- Add minified counterparts (redturtle_chefcookie.min.js, redturtle_chefcookie_tech.min.js, styles.min.css) for the assets that were previously served unminified, and point the viewlet at them. - Add `defer` to the injected <script> tags so they no longer block page rendering. Third-party tracking scripts are still gated via the type="text/plain"/data-cc-src mechanism, which does not depend on execution order, so this is safe. - Add `make minify`/`make check-minified` and a CI workflow that regenerates the minified assets and diffs them against what's committed, to catch a source edited without regenerating its `.min` counterpart (mtime comparison is not reliable in CI since git does not preserve mtimes on checkout).
…ntain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.
Summary
chefcookie.min.js(redturtle_chefcookie.jsandredturtle_chefcookie_tech.js, ~20KB/~15KB) plusstyles.csswere shipped unminified. Added minified counterparts (esbuild) and pointed theredturtle.chefcookiejsviewlet at them.<script>tags injected inIHtmlHeadhad noasync/defer, so they blocked HTML parsing. Addeddefer: execution order is preserved (needed sinceredturtle_chefcookie(.tech).jsextends thechefcookieclass andcookie_config.jsinstantiates it), and third-party tracking scripts are gated via thetype="text/plain"/data-cc-srcrewrite mechanism rather than script load order, so this doesn't weaken cookie-consent gating.make minify/make check-minifiedplus a CI workflow (.github/workflows/minified-assets.yml) that regenerates the minified assets and diffs them against what's committed, so a source edit without a matching minified rebuild fails CI. (An mtime-based check was considered but rejected: git doesn't preserve mtimes on checkout, so it would be a no-op in CI.)Test plan
node --checkon both generated.min.jsfilesredturtlechefcookieclass name and instance method names referenced by name fromcookie_config.py(isAccepted,init,acceptAllScripts, etc.)make check-minifiedpasses clean on current sources; manually verified it fails when a source is changed without regenerating (tested, then reverted)