Removing jQuery migrate and working with dependencies

by Brett   Last Updated July 22, 2018 19:08 PM

I have jQuery setup in my enqueue scripts section as a dependency, such as:

wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.min.js', array( 'jquery' ) );

Now, I want to remove jquery-migrate, but keep jQuery itself obviously, so I found this answer stating to do it like this:

add_filter( 'wp_default_scripts', 'remove_jquery_migrate' );

function remove_jquery_migrate( &$scripts){
        $scripts->remove( 'jquery');
        $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.2.1' );

Firstly, I thought we had removed jQuery migrate here, so not sure what the need of adding the latest version of it is with the comment:

1.2.1 = latest version of jquery-migrate

Secondly, with the way I set my enqueue scripts up, how does that affect the dependencies since I have now removed jQuery and added jquery-core?

Is there a better way to handle this?

Related Questions

Onclick is not working on mobile

Updated January 28, 2019 12:08 PM

Create arrays from multiple functions

Updated May 27, 2016 08:03 AM