1

I'm using the following code to defer all JavaScript files on my site but have struggled with pingbacks and trackbacks; they don't work anymore.

It seems that WordPress is using some JavaScript to detect or send pingbacks and trackbacks out. Does anyone know how the write an exception for pingbacks and trackbacks, or why its not working with this code snippet?

function defer_parsing_of_js( $url ) {
    if (FALSE === strpos($url, '.js')) {
       return $url;
    }

    if (strpos($url, 'jquery.js')) {
        return $url;
    }

    if (is_admin()) {
        return $url;
    }
    return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

Receiving pingbacks and trackbacks is still working without any problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.