function add_defer_attribute($tag, $handle) { if ( 'your-script-handle' === $handle ) { return str_replace( ' src', ' defer="defer" src', $tag ); } return $tag; } add_filter('script_loader_tag', 'add_defer_attribute', 10, 2);