Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Was thinking about this : dequeue or enqueue scripts with IE for example. They say we can use global $is_IE; but that's wrong simply because it's not compatible with caching. Nowadays cache is everywhere !

Does someone have an idea about this?

I mean if I want some styles in IE8 I can do this :

add_action( 'wp_head', '_load_ie_styles' );
function _load_ie_styles() {
  global $wp_styles;
  wp_register_style( 'ie8', get_stylesheet_directory_uri().'/css/style-ie8.css' );
  $wp_styles->add_data( 'ie8', 'conditional', 'if IE 8' );
  wp_enqueue_style( 'ie8' );
}

Ok that's cool ! Maybe if I want something to avoid IE I can do this (not tested) :

add_action( 'wp_head', '_load_ie_styles' );
function _load_ie_styles() {
  global $wp_styles;
  wp_register_style( 'not-ie', get_stylesheet_directory_uri().'/css/style-not-ie.css' );
  $wp_styles->add_data( 'not-ie', 'conditional', 'if !IE' );
  wp_enqueue_style( 'not-ie' );
}

But how to do this with scripts? How can I dequeue scripts condionnally (IE) ?

Hope I'm clear. Does someone have any thought about this?

share|improve this question
1  
Seems there's an explanation here –  JMau Jan 20 at 22:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.