-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent completely tree-shaken styles from triggering excessive CSS #6624
Merged
Conversation
This file contains 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
Plugin builds for b256089 are ready 🛎️!
|
2 tasks
1e70329
to
10ce5cc
Compare
…sheet-concat * 'develop' of github.com:ampproject/amp-wp: (643 commits) Update CODEOWNERS Update amphtml spec to 2111242025000 Use CF7 instead of Autoptimize for AMP-incompatible plugin in E2E tests Replace autoptimize with akismet for E2E tests Pin NodeJS to v14 to match WP core and Gutenberg Regenerate package-lock.json at lockfileVersion 1 Update Gutenberg package dependencies Stop mapping E2E test plugins dir to container volume Add demo plugin ZIP archive Fix script command Fix lint issues Ensure React state updates are not performed on unmounted components Use different Jest configs for E2E tests; use `.env` config file Refactor "Other Settings" E2E tests Ensure selector is available before scrolling element into view Use more robust internal activate/deactivate functions in E2E tests Introduce general `saveSettings` util function for E2E tests Remove unnecessary cleanup functions in E2E tests Install Hestia theme globally as it is used in multiple tests Use local demo plugin in E2E tests ...
…sheet-concat * 'develop' of github.com:ampproject/amp-wp: Add test case for Bento lacking layout attributes; improve test coverage Fix phpcs alignment warning Cast term IDs to integers instead of using sanitize_key() Update Gutenberg package dependencies Use strict check for in_array() and improve comment Derive intrinsic layout when max-width defined Validate supported layouts for converted Bento components; add support for fill and nodisplay Update AMP_Base_Sanitier::set_layout() to account for 100% width/height styles Harmonize Bento component name parsing Fix variable name Fix typos in comments Add support for converting Bento component dimensions from inline styles to AMP layout Further improve test converage and remove dead code Improve test coverage for ID attribute changes Improve Bento sanitizer and add tests Prevent bento components from being treated as light shadow DOM wrappers Prevent JS error on validated URL screen when no validation errors present Fix handling of ID attributes during sanitizer conversion Introduce Bento sanitizer to deal with BentoJS components
delawski
approved these changes
Dec 2, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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
This fixes an issue encountered by @delawski where even though a stylesheet may have zero bytes after tree-shaking, it can still end up causing an “Excessive CSS” validation error. The stylesheet here in question is the emoji styles being printed:
amp-wp/includes/class-amp-theme-support.php
Lines 2195 to 2225 in 73cfc46
After quite a bit of trial and error, I got the stylesheets for the theme to add up to the maximum bytes on the page (which is 75000 minus the byte count for the source map comment). I then added a plugin to add a stylesheet before the AMP emoji styles:
I then created a post which had no emoji on it so that all of the emoji styles would be tree-shaken.
I marked the validation error for the styles from “Add Style To Beginning of Head” as kept to so that those styles would be forcibly added to the page and trigger any other styles as going over the limit.
Notice that the entirely tree-shaken stylesheet is no longer showing as excluded and it is no longer raising a validation error.
Checklist