Skip to main content
FolksSpeakersPluginsThemesEventsSnippetsShippedCommunityResources
Login Join
Snippet · PHP

Move jQuery Script to The Footer

Shared by Nazim Husain · April 27, 2026

6 views
Back to Snippets

Placing the jQuery script in the footer enhances the website’s performance.

add_action( 'wp_enqueue_scripts', function() {
    if ( is_admin() ) {
        return;
    }

    $scripts = wp_scripts();

    if ( isset( $scripts->registered['jquery'] ) ) {
        $scripts->add_data( 'jquery', 'group', 1 );
    }

    if ( isset( $scripts->registered['jquery-core'] ) ) {
        $scripts->add_data( 'jquery-core', 'group', 1 );
    }

    if ( isset( $scripts->registered['jquery-migrate'] ) ) {
        $scripts->add_data( 'jquery-migrate', 'group', 1 );
    }
});