WordPress.org

Make WordPress Core

Opened 3 weeks ago

Last modified 3 weeks ago

#44484 new defect (bug)

Mediaelement scripts forced loaded in header

Reported by: Themezly Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 4.9.6
Component: Media Keywords:
Focuses: Cc:

Description

Before this https://make.wordpress.org/core/2017/10/30/mediaelement-upgrades-in-wordpress-4-9/

media element scripts were loading where called

example:

wp_enqueue_script( 'wp-mediaelement' ); // loads above site-scripts in footer with dependencies 

/*
mediaelement-and-player.min.js
wp-mediaelement.min.js
*/

wp_enqueue_script( 'site-scripts'); // loads in footer as needed

now

mediaelement.min.js mediaelement-core.min.js

load in head and wp-mediaelement.min.js loads in footer

If I call them one by one without calling wp-mediaelement the order is kept

wp_enqueue_script( 'mediaelement-migrate' );// loads in footer
wp_enqueue_script( 'mediaelement-core' );// loads in footer
wp_enqueue_script( 'site-scripts'); // loads in footer

if you look here it is intended for all of them to be in footer

https://github.com/WordPress/WordPress/blob/6a9a5e123c49862babf664367c26c89499fed4e0/wp-includes/script-loader.php#L377-L378

https://github.com/WordPress/WordPress/blob/6a9a5e123c49862babf664367c26c89499fed4e0/wp-includes/script-loader.php#L474

but wp_enqueue_script( 'wp-mediaelement' );

depends on wp_enqueue_script( 'mediaelement' ); http://prntscr.com/k15288

https://github.com/WordPress/WordPress/blob/6a9a5e123c49862babf664367c26c89499fed4e0/wp-includes/script-loader.php#L376

which loads in header only

so we can never move the scripts to footer where they should be

If I set the mediaelement to load in footer everything works as intended.

Change History (1)

#1 @SergeyBiryukov
3 weeks ago

  • Component changed from General to Media
Note: See TracTickets for help on using tickets.