Using defer or async JavaScript attributes prevents pingbacks and trackbacks from being sent

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.

Topic pingbacks comments Wordpress javascript

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.