Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Title: Remove query string from static files
- // Description: Used to remove the version from the URL of the resources
- // of the theme to improve performance and avoid caching issues when updating them.
- function remove_cssjs_ver( $src ) {
- if( strpos( $src, '?ver=' ) )
- $src = remove_query_arg( 'ver', $src );
- return $src;
- }
- add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
- add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );
- // Title: Defer parsing of JavaScript
- // Description: Used to get better performance results by
- // defering parsing of all the JavaScript files inside the header.
- 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 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement