Okay
  Public Ticket #368808
Ho do you defer parsing of Javascript?
Closed

Comments

  • Brian started the conversation

    I'm trying to defer parsing i.e. GTMetrix recommendation. I tried adding this code to the end of the 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' defer ";

    }

    add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

    ?>


    but get these errors:

    Warning: Cannot modify header information - headers already sent by (output started at /home2/gallag68/public_html/leadrabbit.com/wp-content/themes/salient/functions.php:7236) in/home2/gallag68/public_html/leadrabbit.com/wp-includes/option.php on line 748

    Warning: Cannot modify header information - headers already sent by (output started at /home2/gallag68/public_html/leadrabbit.com/wp-content/themes/salient/functions.php:7236) in/home2/gallag68/public_html/leadrabbit.com/wp-includes/option.php on line 749

  •  1,075
    ThemeNectar replied

    Hey - have you tried using a plugin in regards such as https://wordpress.org/plugins/wp-deferred-javascri... ?

  • Brian replied

    Yeah I did try that one & it made the slider invisible. Speed Booster pack did work for me though.