Use Google's CDN-hosted jQuery Instead of using the default jQuery host, you just need to embed the jQuery insert tag from the jQuery...
Use Google's CDN-hosted jQuery
Instead of using the default jQuery host, you just need to embed the jQuery insert tag from the jQuery file available on Google's CDN server. The advantage of this approach is the bandwidth savings and limited handling of jQuery. Continue to open childtheme's Fuction.php file and add the following code./** Remove jQuery and jQuery-ui scripts loading from header */Compresses Javascript and brings down the footer
add_action('wp_enqueue_scripts', 'crunchify_script_remove_header');
function crunchify_script_remove_header() {
wp_deregister_script( 'jquery' );
wp_deregister_script( 'jquery-ui' );
}
/** Load jQuery and jQuery-ui script just before closing Body tag */
add_action('genesis_after_footer', 'crunchify_script_add_body');
function crunchify_script_add_body() {
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js' );
wp_register_script( 'jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js' );
wp_enqueue_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js', array( 'jquery' ), '4.0', false );
wp_enqueue_script( 'jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', array( 'jquery' ), '1.10.3' );
}
The Genesis framework has a very fast load speed (which is already optimized), but by default the theme's JavaScript files will be preloaded to ensure the functionality functions as programmed. You can also use the async async load function, but it will cause problems on the menu on the phone very annoying. The best way is to move these JS snippets to footers. The job is quite simple, just go to Cpanel> Public_html> wp-content> File childtheme> open File Fuction.php and paste the following code in and save.
//* Chuyen JS xuong footer
function remove_head_scripts() {
remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
add_action('wp_footer', 'wp_print_scripts', 5);
add_action('wp_footer', 'wp_enqueue_scripts', 5);
add_action('wp_footer', 'wp_print_head_scripts', 5);
}
add_action( 'wp_enqueue_scripts', 'remove_head_scripts' );
No comments:
Post a Comment