[wp-trac] [WordPress Trac] #61435: Style dependencies are not inlined

WordPress Trac noreply at wordpress.org
Thu Jun 13 14:24:13 UTC 2024


#61435: Style dependencies are not inlined
---------------------------+-----------------------------
 Reporter:  mosne          |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  5.8
 Severity:  normal         |   Keywords:
  Focuses:  performance    |
---------------------------+-----------------------------
 in #50836 we added the ability to inline styles but

 style dependencies to specific styles are not automatically inlined
 eventhough a path is provided.

 The problem :

 {{{
 wp_register_style( 'alice', $url_alice );
 wp_style_add_data( 'alice', 'path', $path_alice );
 wp_register_style( 'bob', $url_bob, array( 'alice' ) );
 wp_enqueue_style( 'bob' );

 // output
 // <link rel='stylesheet' id='alice-css' href='...' media='all' />
 // <link rel='stylesheet' id='bob-css' href='...' media='all' />
 }}}



 The expected result is to have **alice** inline before **bob**.
 But **alice** is always loaded as external resources.

 To achieve **alice** inline I have to manually wp_enqueue_style **alice**.

 {{{
 wp_enqueue_style( 'alice' );
 wp_enqueue_style( 'bob' );

 // output
 // <style id='alice-inline-css'>...</style>
 // <link rel='stylesheet' id='bob-css' href='...' media='all' />

 }}}

 Currently, wp_maybe_inline_styles only checks on enqueued styles

 We should recheck if dependencies could be output inline.


 How to reproduce: in attachment a child theme.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61435>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list