How To Defer Parsing Javascript in WordPress

This topic contains 3 replies, has 2 voices, and was last updated by  Paolo 9 years, 7 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #36259

    Alec
    Lifetime Member
    Post count: 319

    I have seen many places recommending defering javascript.

    I found this code to install in the functions.php file:
    _______________________________________________________________

    // Defer Javascripts
    // Defer jQuery Parsing using the HTML5 defer property
    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 );
    }

    __________________________________________________________________________

    Do you think this would be ok to add?

    #36360

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I think it would casue problems if added, it might work for some scripts, but not all.

    I wouldn’t use it.

    Thanks

    #36382

    Alec
    Lifetime Member
    Post count: 319

    Ok,

    What about this tool to clean up the wp databases and remove old files, seems to be very popular tool to do this. Do you think it conflicts with wpgeo?

    https://wordpress.org/plugins/wp-optimize/

    #36424

    Paolo
    Site Admin
    Post count: 31206

    No it shouldn’t create any conflict.

    Thanks

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount