Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#35957 closed defect (bug) (duplicate)

wp_register_script loads all dependencies in head even if some dependencies are specified to load in footer.

Reported by: pderksen Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Script Loader Keywords:
Focuses: javascript Cc:


In the following example, child-footer should render in the footer right before parent, but instead is rendered in the head right after 'child-head'.

function my_enqueue_scripts() {
        wp_register_script( 'child-head', '/child-head.js', array(), null, false );
        wp_register_script( 'child-footer', '/child-footer.js', array(), null, true );
        wp_register_script( 'parent', '/parent.js', array( 'child-head', 'child-footer' ), null, true );
        wp_enqueue_script( 'parent' );

add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );

Possibly related: #35873

Change History (2)

#1 @ocean90
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #35956.

#2 @pderksen
6 years ago

Wow you beat me to it by 12 minutes @stephenharris. Nicely done! :)

Note: See TracTickets for help on using tickets.