Extend CSS tree shaking to remove selectors for non-existent IDs and elements #1142
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.
If a CSS selector contains a reference to an ID, like
#subscribe-email input { ... }
and there is no element with the ID ofsubscribe-email
in the document, then this CSS rule should be removed. Additionally, if a CSS selector includes a reference to a tag name for an element that doesn't exist in the document, then this CSS selector should also be removed from the document.On Twenty Fifteen without these changes, the CSS is 42421 bytes. With this branch, the CSS is 35114 bytes. So about 20% smaller.
This also removes trailing semicolons from rules to save additional bytes.