Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Introduce stylesheet prioritization when determining which to concatenate #2346
A theme's stylesheets should never be excluded in favor of the admin bar CSS. Similarly, print stylesheets should never be included at the expense of plugin stylesheets. This PR introduces prioritization when determining which stylesheets to include and which to exclude when the tree shaker is not able to reduce the total CSS to the 50KB limit. The changes here should result in a drastic reduction in the frequency of a theme appearing completely broken when viewing in Native/Transitional modes.
The stylesheet priorities are:
If it so happens that the Admin Bar CSS is excluded, then the HTML element for the admin bar as well as its associated CSS are both excluded.
Since the admin bar is automatically excluded, there is now no need for the option and it is removed:
Other items for follow-up
I'm not sure what to do about these two points:
There is an indication now but it is just an HTML comment, so it could still be disorienting to a user who expects the admin bar to be present. Otherwise, the way that a user could discover that the admin bar is being excluded by re-validating the URL via the compatibility tool:
On Native mode in particular, they could decide to reject the validation error to cause the admin bar to appear, though with the warning as expected:
This would not be advisable in Transitional mode because the rejected state would then cause the
This is looking sharp! I am not too familiar with the sanitizers yet, especially the one for stylesheets. That's why I cannot give detailed feedback on the general approach and the todos you added. But after going through the code and testing it with a few themes, this seems to work as expected.
Happy to give it a more thorough spin tomorrow though. Alternatively, I imagine that @kienstra might know this area better than I and could also provide some more valuable feedback? Correct me if I'm wrong
Agreed, let's take this step by step.
If we did this we'd still need to include the CSS for the admin bar, at least a subset of it. And the
I was giving it some more thought last night about what do do and I'm thinking this: if the user is authenticated, we should skip
I guess this is just re-hashing #1921.