Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.