I am trying to download some of my scripts from CDN, such as CDNjs and Google. The scripts load correctly, but for some reason I can’t find, for each script I have two or even three HTTP requests (For the same script), here is an example: http://tools.pingdom.com/fpt/#! /ePuR3Z/http://elbauldelprogramador.com .
I noticed that when I logged in, all the scripts generate only one HTTP request.
JQuery from ajax.googleapis generates two http requests and jquery.easing.min.js from cdnjs three.
Code:
function modify_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js', false, '2.0.3');
wp_enqueue_script('jquery');
}
}
add_action('init','modify_jquery');
I have a child theme, and from its parent I copied the wi_enqueue () function. In the parent element, the function looks like this:
add_action( 'wp_enqueue_scripts', 'wi_enqueue' );
if ( !function_exists('wi_enqueue') ) {
function wi_enqueue(){
}
In my child function.php, I have:
function wi_enqueue(){
global $wp_styles, $smof_data;
wp_enqueue_script( 'wi-easing', '//cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js', array('jquery'), '1.3', true );
wp_enqueue_script( 'wi-touchswipe', '//cdnjs.cloudflare.com/ajax/libs/jquery.touchswipe/1.6.4/jquery.touchSwipe.min.js', array('jquery'), '1.3.3', true );
wp_enqueue_script( 'wi-autosize', '//cdnjs.cloudflare.com/ajax/libs/autosize.js/1.17.1/autosize-min.js', array('jquery'), '1.17.1', true );
wp_enqueue_script( 'wi-placeholder', '//cdnjs.cloudflare.com/ajax/libs/placeholders/2.1.0/placeholders.min.js', array('jquery'), '2.1.0', true );
wp_enqueue_script( 'wi-modernizr', get_template_directory_uri() . '/js/modernizr.custom.15463.js', array('jquery'), '2.6.2', true );
wp_enqueue_script( 'wi-waypoint', '//cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.2/waypoints.min.js', array('jquery'), '2.0.2', true );
wp_enqueue_script( 'wi-tipsy', get_template_directory_uri() . '/js/jquery.tipsy.js', array('jquery'), '1.0.0', true );
wp_enqueue_script( 'wi-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array('jquery'), '1.0', true );
wp_enqueue_script( 'wi-sidr', get_template_directory_uri() . '/js/jquery.sidr.min.js', array('jquery'), '1.1.1', true );
}