Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. function js_async_attr($tag)
  2. {
  3. if ( !is_user_logged_in() )
  4. {
  5. $scripts_to_exclude = array('script1.js', 'script2.js', 'script3.js');
  6. foreach($scripts_to_exclude as $exclude_script)
  7. {
  8. if(true == strpos($tag, $exclude_script ))
  9. return $tag;
  10. }
  11. return str_replace( ' src', ' defer async src', $tag );
  12. }
  13. }
  14. add_filter( 'script_loader_tag', 'js_async_attr', 10 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement