nov 072015
 

Er zijn meerdere versies:

add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );
// add async and defer to javascripts
function wcs_defer_javascripts ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.js' ) ) return $url;
    return "$url' async='async";
}
add_filter( 'clean_url', 'wcs_defer_javascripts', 11, 1 );

Gevonden op: http://wpcodesnippet.com/add-async-and-defer-attributes-javascript-elements/
Na lang zoeken en uitproberen.

function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, ‘.js’ ) ) return $url;
if ( strpos( $url, ‘jquery.js’ ) ) return $url;
return “$url’ defer=’defer”;
}
add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );