June 24, 2013

Simple Defer Parsing Of Javascript Tip To Speed Up Website Load Time

|
Here is one way to defer parsing of Javascript to speed up your website.

This is what you need to do:

1. Copy the code below and paste it on your functions.php file.

<?php
function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.js' ) ) return $url;
    return "$url' async onload='myinit()";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
?>


2. Click Update File.