0

Is it possible to dequeue scripts in IE7 only using functions.php? I have my scripts configured in the following way:

// JS
function scripts() {
  // Register scripts & styles
  wp_register_script( 'responsive_nav', get_template_directory_uri() . '/js/responsive-nav.js', '', '', false );
  wp_register_script( 'initialize_lightbox', get_template_directory_uri() . '/js/initialize_lightbox.js', 'jquery', '', true );
  wp_register_script( 'lightbox', get_template_directory_uri() . '/js/lightbox.js', 'jquery', '', true );
  wp_register_style( 'lightbox_styles', get_template_directory_uri() . '/css/lightbox.css', array(), '', 'all' );

  // Enqueue
  wp_enqueue_script( 'responsive_nav' );
  wp_enqueue_script( 'initialize_lightbox' );
  wp_enqueue_script( 'lightbox' );
  wp_enqueue_style( 'lightbox_styles' );

}
add_action( 'wp_enqueue_scripts', 'scripts' );

Thanks!

Squid

2 Answers 2

1

WordPress has built-in browser detection mechanism. And they set a global variable $is_IE.

function scripts()
{
    global $is_IE;
    if( ! $is_IE ){
        // Register scripts & styles
        // Enqueue
    }
}
add_action( 'wp_enqueue_scripts', 'scripts' );
0

Here is a great way to check which version of IE you facing

https://stackoverflow.com/a/1042194/915636

As for the part about deregistering scripts..

here is an example:

$browser = get_browser();

if($browser->browser == 'IE' && $browser->majorver == 6) {
    // DO NOTHING
} elseif($browser->browser == 'IE' && $browser->majorver == 7) {
    wp_deregister_style('some_script_id');
    wp_dequeue_style('some_script_id');
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.