[wp-trac] [WordPress Trac] #58775: Remove usage of outputting styles tags
WordPress Trac
noreply at wordpress.org
Thu Sep 21 12:28:02 UTC 2023
#58775: Remove usage of outputting styles tags
-----------------------------------------+---------------------------
Reporter: spacedmonkey | Owner: spacedmonkey
Type: enhancement | Status: assigned
Priority: normal | Milestone: 6.4
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: has-patch close 2nd-opinion | Focuses:
-----------------------------------------+---------------------------
Comment (by spacedmonkey):
Replying to [comment:16 azaozz]:
> > is not great. As these values are hard to filter and control the
output of.
>
> That's not exactly true. Seems most of these are done from hooks and
plugins can replace them very easily.
>
> > These places should all be replaced with wp_add_inline_style or use
the WP_Style enqueueing system.
>
> Why? I see two disadvantages to doing this:
>
> 1. It is slower and uses more server resources. Maybe not by much, but
using Script Loader will make all of these slower.
>
> 2. Seems all of these were intended to work as they do now. What are the
reasons to change this (other than "lets use the new stuff!"). Unless
there are some good reasons and examples why these should be changed, this
can be considered a "pointless refactor for the sake of refactoring". As
such it generally would go against the WP best practices.
This issue was created because plugins like [https://en-
gb.wordpress.org/plugins/autoptimize/ autoptimize], are used to optimize
css rendered on the page. This does so by concatenating all enqueued css
into one blob. As this css is not enqueued correctly, then this is not
possible.
There is nothing wrong with using WordPress it's own API to output CSS.
The only reason that it was not used before in many cases, as this inline
styles did not exist.
This change does the following.
1. Allows plugins to include these styles in css optimize.
2. Allows developers to unqueue these styles.
3. Makes it easier to maintain the these styles, as all styles are output
in the same way.
4. Addes constituency to the code.
This is not a refactor for the sake of refactor.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58775#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list