[wp-trac] [WordPress Trac] #58775: Remove usage of outputting styles tags

WordPress Trac noreply at wordpress.org
Mon Sep 25 21:44:29 UTC 2023


#58775: Remove usage of outputting styles tags
--------------------------------+---------------------------
 Reporter:  spacedmonkey        |       Owner:  spacedmonkey
     Type:  enhancement         |      Status:  reopened
 Priority:  normal              |   Milestone:  6.4
Component:  Script Loader       |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  2nd-opinion revert  |     Focuses:  performance
--------------------------------+---------------------------

Old description:

> There are a number of places in core where style tags are manually built
> and output. Examples
>
> - print_emoji_styles
> - the_block_template_skip_link
> - print_embed_styles
>
> Instead of manually build tags like this, is not great. As these values
> are hard to filter and control the output of. These places should all be
> replaced with `wp_add_inline_style` or use the `WP_Style` enqueueing
> system.

New description:

 There are a number of places in core where style tags are manually built
 and output. Examples

 - print_emoji_styles
 - the_block_template_skip_link
 - print_embed_styles

 Instead of manually build tags like this, is not great. As these values
 are hard to filter and control the output of. These places should all be
 replaced with `wp_add_inline_style` or use the `WP_Style` enqueueing
 system.

 This change does the following.
 * Allows plugins to include these styles in css optimize.
 * Allows developers to unqueue these styles.
 * Makes it easier to maintain the these styles, as all styles are output
 in the same way.
 * Adds constituency to the code.

--

Comment (by hellofromTonya):

 Updating the description to include the details @spacedmonkey shared in
 #comment:20.

 More context about this reasoning for this ticket shared during today's
 scrub:

 Is this a performance ticket? No, as @flixos90
 [https://wordpress.slack.com/archives/C02RQBWTW/p1695675668407189 noted in
 today's scrub discussion]:

 >Performance itself should not be changed by this commit, neither to the
 positive nor negative.

 As @joemcgill
 [https://wordpress.slack.com/archives/C02RQBWTW/p1695675638815579 shared,
 it gives the potential for optimization by performance plugins]:
 >My understanding is that the intent is to allow these styles to be
 optimized by performance optimization plugins. Currently that's not
 possible because these are not output using the standard WP Scripts APIs.

 As @flixos90
 [https://wordpress.slack.com/archives/C02RQBWTW/p1695675929516229 shared,
 it allows other styles dependencies]:
 >The other benefit of the change is that it allows for other styles to
 depend on those styles. For example, additional WP Embed styles in a
 plugin could now use something like `wp_enqueue_script( $handle,
 $stylehsheet_file, 'wp-embed-template' )`, and it would ensure they are
 printed in the correct order

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58775#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list