Skip to content

Instantly share code, notes, and snippets.

@craigsimps
Created November 14, 2016 01:07
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 craigsimps/faa4622132df2c6dc1d86326293ae582 to your computer and use it in GitHub Desktop.
Save craigsimps/faa4622132df2c6dc1d86326293ae582 to your computer and use it in GitHub Desktop.
Adding a script in WordPress, with IE conditional.
add_action( 'wp_enqueue_scripts', 'cs_conditional_scripts_and_styles' );
/**
* Enqueue styles and scripts conditionally.
*
* @link https://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx
* @since 1.0.0
*/
function cs_conditional_scripts_and_styles() {
/**
* Enqueue flexiility.js script for users of IE9 and below.
* @link: https://github.com/10up/flexibility
*/
wp_enqueue_script( 'flexibility', get_stylesheet_directory_uri() . '/assets/js/flexibility.js', [], '20160502', true );
wp_script_add_data( 'flexibility', 'conditional', 'lte IE 9' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment