defer parsing of JavaScript on Tempera theme

  • Author
  • #84638
    Power User

    I’m trying to improve the page loading speed of my site.
    GTmetrix says I need to address ‘defer parsing of JavaScript.’
    I’ve tried different plugins, but this hasn’t worked.

    It was suggested I paste the following into ‘Theme functions’ section of Tempera theme:

    * Defer parsing of javascript.
    if (!(is_admin() )) {
    function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, ‘.js’ ) ) return $url;
    if ( strpos( $url, ‘jquery.js’ ) ) return $url;
    // return “$url’ defer “;
    return “$url’ defer onload='”;
    add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );

    But this hasn’t worked either.
    can you please advise on how best to resolve this issue.

    Thank you very much


    Cryout Creations Team

    The clean_url filter appears to be used internally for string formatting, not on URLs output.

    I suggest taking a look at the script_loader_tag filter instead, but keep in mind deferring scripts can make code not aware of deferring fail or malfunction.

    If you like our creations, help us share by rating them on
    Please read the available documentation and search the forums before posting.
    Power User

    Thanks for your advice

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘defer parsing of JavaScript on Tempera theme’ is closed to new replies.