Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#63179 new defect (bug)

Dependencies should load in the footer if the script is loaded in the footer

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

Description

Followup to https://core.trac.wordpress.org/ticket/35956

<?php
wp_register_script('parent','parent.js', array('child'), '1', array( 'in_footer' => true ) );
wp_register_script('child', 'child.js', array(), '1' );
wp_enqueue_script('parent');

This will print "child" in head, but parent in the footer.
But child should print in the footer too I guess, since it's just loaded as dependency?

I assume this is bc of https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/class-wp-scripts.php#L314C6-L314C22 with docs:

  1. The intended strategy is delayed.

Why does the intended strategy matter here for the dependency?
Removing that condition should fix it (not tested, just assuming it from what I see in the code)

Change History (1)

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


5 weeks ago

Note: See TracTickets for help on using tickets.