Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1422698

    abel.bongot
    Participant

    Hi I’m using autoptimize and wp fastest cache for optimizing my site. Our team used WP Total cache before but we decided to change to WP Fastest Cache for some reason. But still I only have a grade of F in GTMETRIX in Defer parsing of Javascript. Can you help me from this?

    #1422973

    Thai
    Moderator

    Hi There,

    Please add the following code under functions.php file locates in your child theme:

    if (!(is_admin() )) {
    	function defer_parsing_of_js ( $url ) {
    		if ( FALSE === strpos( $url, '.js' ) ) return $url;
    		if ( strpos( $url, 'jquery.js' ) ) return $url;
    		if ( strpos( $url, 'x-head.min.js' ) ) return $url;
    		return "$url' defer='defer";
    	}
    	add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
    }

    Hope it helps 🙂

    #1423815

    abel.bongot
    Participant

    thanks!

    #1423919

    Rahul
    Moderator

    You are Welcome.

    Thank you for choosing X. Cheers!