Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#61435 new defect (bug)

Style dependencies are not inlined

Reported by: mosne's profile mosne Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.8
Component: Script Loader Keywords:
Focuses: Cc:

Description

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.

Attachments (1)

twentytwentyfour-child.zip (2.1 KB) - added by mosne 6 weeks ago.

Download all attachments as: .zip

Change History (3)

#1 @joemcgill
6 weeks ago

  • Focuses performance removed

Thanks for the report, @mosne. I think you meant to link to this commit [50836] rather than the ticket with the same number. For additional context, the ability to pass path as a value to the second parameter was documented in #53792.

#2 @mosne
5 weeks ago

Yes indeed I was referring to the changeset (https://core.trac.wordpress.org/changeset/50836) if someone can fix the ticket description it would be great (because I don't have editing capabilities) thanks!

Note: See TracTickets for help on using tickets.