Tree-shake CSS selectors for HTML elements that target non-active languages #1221
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.
In Twenty Seventeen there is about 5KB+ of rules with selectors to add styles that are specific to various languages:
https://github.com/WordPress/wordpress-develop/blob/a830dbcab3147e67b3076d3d15c89975df675fbb/src/wp-content/themes/twentyseventeen/style.css#L582-L913
Based on the site's locale, we should only include the rules that are relevant. In other words, this is attribute-based tree-shaking for the root element. It doesn't really make sense for all of these to be always served in the CSS. Note that amp-bind'ed
[lang]
is not allowed, so there is not the concern that they will become relevant later: the language won't be changed at runtime.The changes in this PR reduce the resulting CSS size from 33,129 bytes down to 27,741 bytes on an example page in English, a 16% reduction.