5 Made some corrections to prevent problems for other users in the back-end, added some extra info to keep all correct.
source | link

Edit - Changed code below to prevent errors/weird behavior in back-end. Source found here!

functionif add_defer_to_js( $url ) {

   ! //function_exists( Be'add_defer_to_js' sure) using&& this! onlyis_admin() on) Front-end!{

    iffunction add_defer_to_js(! is_admin()$url ) {

        if ( FALSE === strpos( $url, '.js' ) ) { 
            // not our file
            return $url;
        }

        // Must be a ', not "!
        return "$url' defer='defer";
    }
}
    add_filter( 'clean_url', 'add_defer_to_js', 11, 1 );
}

Edit - Extra info: remove following from the function below http://yourdomain.com for normal use.

function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate'migrate.min' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate'migrate.min', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.min.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate'migrate.min', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.min.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;
function add_defer_to_js( $url ) {

    // Be sure using this only on Front-end!
    if (! is_admin() ){

        if ( FALSE === strpos( $url, '.js' ) ) {
            return $url;
        }

        // Must be a ', not "!
        return "$url' defer='defer";
    }
}
add_filter( 'clean_url', 'add_defer_to_js', 11, 1 );
function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;

Edit - Changed code below to prevent errors/weird behavior in back-end. Source found here!

if ( ! function_exists( 'add_defer_to_js' ) && ! is_admin() ) {

    function add_defer_to_js( $url ) {

        if ( FALSE === strpos( $url, '.js' ) ) { 
            // not our file
            return $url;
        }

        // Must be a ', not "!
        return "$url' defer='defer";
    }
    add_filter( 'clean_url', 'add_defer_to_js', 11, 1 );
}

Edit - Extra info: remove following from the function below http://yourdomain.com for normal use.

function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate.min' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate.min', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.min.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate.min', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.min.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;
4 deleted 4 characters in body
source | link
function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate-min'migrate' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;
function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate-min' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;
function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;
3 Formatted code slightly and grammar
source | link

First of all, this is what I use and for me and it works,. I'm not saidsaying that my code is 100% correct but, Pingdom aswellas well GTmetrix show a positive effect, and WP is satisfied also, so it can't be that wrong as I do.

The versions showing (?ver=x.x.x) can be debet when those files need to be cached so stripping(filter) that is already a first step.
 

The code snippet I use for this looks like this:
 


To To add defer (Google loves to see this also) *.js files (for a positive pagespeed) I use following snippet:
 

function add_defer_to_js( $url ) {

    // Be sure using this only on Front-end!
    if (! is_admin() ){

        if ( FALSE === strpos( $url, '.js' ) ) {
            return $url;
        }

        // Must be a ', not "!
        return "$url' defer='defer";
    }
}
add_filter( 'clean_url', 'add_defer_to_js', 11, 1 );


To To add .js files now into the footer (helps pages loading) we can enqueue them with following snippet:
 

function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate-min' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;

All together, these 3 functions(add in the functions.phpfunctions.php) should help loading ouryour pages faster, caching them correctly.

Hope this helps a little, and making. Making a copy of your functions.phpfunctions.php before adding these functions is not a bad idea at all. (adding the functions at the bottom of your functions.phpfunctions.php is imho the best way).

Note:Note: I am not using a child theme, and till now it causes no conflict with the plugins as used. I little warning/hint, and correct me if I am wrong but to enqueue .js files for a child theme, that should slightly done different.

First of all, this is what I use and for me it works, not said that my code is 100% correct but, Pingdom aswell GTmetrix show a positive effect, and WP is satisfied also, so it can't be that wrong as I do.

The versions showing (?ver=x.x.x) can be debet when those files need to be cached so stripping(filter) that is already a first step.
 

The code snippet I use for this looks like this:
 


To add defer (Google loves to see this also) *.js files (for a positive pagespeed) I use following snippet:
 

function add_defer_to_js( $url ) {

    // Be sure using this only on Front-end!
    if (! is_admin() ){

        if ( FALSE === strpos( $url, '.js' ) ) {
        return $url;
        }

        // Must be a ', not "!
        return "$url' defer='defer";
    }
}
add_filter( 'clean_url', 'add_defer_to_js', 11, 1 );


To add .js files now into the footer (helps pages loading) we can enqueue them with following snippet:
 

function enqueue_scripts_in_footer() {

wp_deregister_script( 'jquery' );
wp_deregister_script( 'jquery-migrate-min' );
wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
wp_register_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;

All together, these 3 functions(add in the functions.php) should help loading our pages faster, caching them correctly.

Hope this helps a little, and making a copy of your functions.php before adding these functions is not a bad idea at all. (adding the functions at the bottom of your functions.php is imho the best way)

Note: I am not using a child theme, and till now it causes no conflict with the plugins as used. I little warning/hint, and correct me if I am wrong but to enqueue .js files for a child theme, that should slightly done different.

First of all this is what I use and for me and it works. I'm not saying that my code is 100% correct but Pingdom as well GTmetrix show a positive effect and WP is satisfied also, so it can't be that wrong as I do.

The versions showing (?ver=x.x.x) can be debet when those files need to be cached so stripping(filter) that is already a first step.

The code snippet I use for this looks like this:

To add defer (Google loves to see this also) *.js files (for a positive pagespeed) I use following snippet:

function add_defer_to_js( $url ) {

    // Be sure using this only on Front-end!
    if (! is_admin() ){

        if ( FALSE === strpos( $url, '.js' ) ) {
            return $url;
        }

        // Must be a ', not "!
        return "$url' defer='defer";
    }
}
add_filter( 'clean_url', 'add_defer_to_js', 11, 1 );

To add .js files now into the footer (helps pages loading) we can enqueue them with following snippet:

function enqueue_scripts_in_footer() {

    wp_deregister_script( 'jquery' );
    wp_deregister_script( 'jquery-migrate-min' );
    wp_register_script( 'jquery', 'http://yourdomain.com/wp-includes/js/jquery/jquery.js', array(), false, true );
    wp_register_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
    wp_enqueue_script( 'jquery', 'http://yourdomain/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'jquery-migrate', 'http://yourdomain.com/wp-includes/js/jquery/jquery-migrate.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );;

All together, these 3 functions(add in the functions.php) should help loading your pages faster, caching them correctly.

Hope this helps a little. Making a copy of your functions.php before adding these functions is not a bad idea at all (adding the functions at the bottom of your functions.php is imho the best way).

Note: I am not using a child theme, and till now it causes no conflict with the plugins as used. I little warning/hint, and correct me if I am wrong but to enqueue .js files for a child theme, that should slightly done different.

2 replaced function(made mistake)/typo's
source | link
1
source | link