Created
February 28, 2018 12:30
-
-
Save perezdans/62321e9d00bf404e3205ce901f9dbcba to your computer and use it in GitHub Desktop.
Poner un attr defer en todos los javascript para optimizar la carga de la página. Sacado de ayudawp.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Aplazar JavaScripts | |
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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment