Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active January 3, 2020 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanaf1979/5fb59ecca45e2273e673fd24f168292d to your computer and use it in GitHub Desktop.
Save vanaf1979/5fb59ecca45e2273e673fd24f168292d to your computer and use it in GitHub Desktop.
Add a action to enqueue stylesGist for my "WorpdPress: Css Styles and Javascripts in theme development (In depth)" article: https://since1979.dev/wordpress-css-styles-and-javascripts-in-theme-development-in-depth/
<?php
/* Remove type attributes from link tags */
function my_theme_optimize_style_tags( $html , $handle , $href , $media )
{
return "<link rel='stylesheet' id='{$handle}' href='{$href}' media='{$media}' />" . "\n";
}
add_filter('style_loader_tag', 'my_theme_optimize_style_tags', 10, 4);
/* Remove type attributes from script tags */
function my_theme_optimize_script_tags( $tag , $handle , $src )
{
return "<script id='{$handle}' src='{$src}'></script>" . "\n";
}
add_filter('script_loader_tag', 'my_theme_optimize_script_tags', 10, 3);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment