Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // Title: Remove query string from static files
  2. // Description: Used to remove the version from the URL of the resources
  3. // of the theme to improve performance and avoid caching issues when updating them.
  4. function remove_cssjs_ver( $src ) {
  5. if( strpos( $src, '?ver=' ) )
  6. $src = remove_query_arg( 'ver', $src );
  7. return $src;
  8. }
  9. add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
  10. add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );
  11.  
  12. // Title: Defer parsing of JavaScript
  13. // Description: Used to get better performance results by
  14. // defering parsing of all the JavaScript files inside the header.
  15. function defer_parsing_of_js ( $url ) {
  16. if ( FALSE === strpos( $url, '.js' ) ) return $url;
  17. if ( strpos( $url, 'jquery.js' ) ) return $url;
  18. return "$url' defer ";
  19. }
  20. add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement