Loading jQuery in the footer after removing jQuery migrate?

There is much safer way of removing jquery-migrate… Your code is almost correct, but first you remove jQuery and then add it again. If dependencies for jQuery will change, then your code will cause problems.

But you don’t have to remove script to change its dependencies. You can do exactly that:

function remove_jquery_migrate( $scripts ) {
    if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
        $script = $scripts->registered['jquery'];

        if ( $script->deps ) {
            $script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
        }
    }
} 
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );

It’s much safer, since we remove only one dependency that we want to be removed.

And if you want to move jQuery to footer, then you can use this code:

function remove_jquery_migrate( $scripts ) {
    if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
        $script = $scripts->registered['jquery'];

        if ( $script->deps ) {
            $script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
        }

        $scripts->add_data( 'jquery', 'group', 1 );
        $scripts->add_data( 'jquery-core', 'group', 1 );
    }
} 
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );

Again – we don’t remove any scripts and add our own, but modify existing scripts only, so it’s much more secure approach.

error code: 523