1

I get this when I check my site in google insight:

google insight

Pretty ok right? But I still consider to fix Eliminate render-blocking JavaScript and CSS in above-the-fold content to get a good results on mobiles too.

I am adding CSS, JS files using the code below:

/* loading the default styles of the theme */
function theme_style_sheets() {
    wp_enqueue_style( 'google-font', 'http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800', '', '1.0.0'  );   
    wp_enqueue_style( 'theme-style', get_template_directory_uri() . 'style.css', '', '1.0.0'  );   
    wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.css', '', '1.0.0'  );   
    wp_enqueue_style( 'bootstrap-responsive', get_template_directory_uri() . '/css/bootstrap-responsive.css', '', '1.0.0' );
    wp_enqueue_style( 'camera', get_template_directory_uri() . '/css/camera.css', '', '1.0.0' );
    wp_enqueue_style( 'docs', get_template_directory_uri() . '/css/docs.css', '', '1.0.0' );
    wp_enqueue_style( 'prettyphoto', get_template_directory_uri() . '/css/prettyPhoto.css', '', '1.0.0' );
    wp_enqueue_style( 'theme', get_template_directory_uri() . '/css/theme.css', '', '1.0.0' );
    wp_enqueue_style( 'tango-skin', get_template_directory_uri() . '/css/skins/tango/skin.css', '', '1.0.0' );
}
add_action( 'wp_enqueue_scripts', 'theme_style_sheets' );

/**
 * loading the default scripts of the theme
 */
function theme_scripts() {      
    wp_enqueue_script( 'jquer-easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array(), '1.0.0', true );
    wp_enqueue_script( 'jquer-mobile', get_template_directory_uri() . '/js/jquery.mobile.customized.min.js', array(), '1.0.0', true );
    wp_enqueue_script( 'camera', get_template_directory_uri() . '/js/camera.js', array(), '1.0.0', true );
    wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.js', array(), '1.0.0', true );
    wp_enqueue_script( 'superfish', get_template_directory_uri() . '/js/superfish.js', array(), '1.0.0', true );
    wp_enqueue_script( 'jquer-prettyphoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array(), '1.0.0', true );
    wp_enqueue_script( 'jquer-jcarousel', get_template_directory_uri() . '/js/jquery.jcarousel.js', array(), '1.0.0', true );
    wp_enqueue_script( 'jquer-tweet', get_template_directory_uri() . '/js/jquery.tweet.js', array(), '1.0.0', true );
    wp_enqueue_script( 'myscript', get_template_directory_uri() . '/js/myscript.js', array(), '1.0.0', true );  
}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );

function load_external_jQuery() { // load external file  
    wp_deregister_script( 'jquery' ); // deregisters the default WordPress jQuery  
    wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"), false);   
    wp_enqueue_script('jquery');    
}  
add_action('wp_enqueue_scripts', 'load_external_jQuery');

So as per the above code the JS files should be loaded in footer and those are loading into the footer. BUT still google includes those files in Eliminate render-blocking JavaScript and CSS in above-the-fold content why ??

Also I've tried differ method like : http://moz.com/community/q/fixing-render-blocking-javascript-and-css-in-the-above-the-fold-content But the out put remains same.

Also in that method I have to combine all the JS / CSS files. I do not want to combine all files into one.

I tried some other snippets too for differing multiple files. Also the out put is same.

Now google insight shows this:

Google insight 2

How can I solve this WITHOUT using any plugin.????

There are plenty of plugins to do this. But I do not use any plugin in my current site and I like to keep avoiding plugins.

-1

put this code at the end of functions.php

add_action('customize_register', 'customizer');
function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.js' ) ) return $url;
    return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.