WordPress.org

Support

Support » WP-Advanced » enqueue javascript js with conditional comments (for IE)

enqueue javascript js with conditional comments (for IE)

  • Working in the theme’s functions.php, how can I wp_enqueue_script a javascript file with conditional comments (for IE)?

    On the inclusion of CSS, wp_enqueue_style supports this for CSS with the following, for example:
    $wp_styles->add_data( ‘theme-ie6’, ‘conditional’, ‘lt IE 7’ );

    Results output:
    <!–[if lt IE 7]>
    <link rel=’stylesheet’ id=’theme-ie6-css’ href=’/wp-content/themes/test/style_ie6.css?ver=1.0.0′ type=’text/css’ media=’all’ />
    <![endif]–>

    I thought the same techniques should work for wp_enqueue_script but I have not been successful.

    DESIRED RESULT on page/post/etc:
    <!–[if lt IE 9]>
    <script src=”http://html5shiv.googlecode.com/svn/trunk/html5.js”></script>
    <![endif]–>

    CODE TO ACHIEVE? (in functions.php of theme):
    global $wp_scripts;
    wp_register_script(‘html5shiv’,’http://html5shiv.googlecode.com/svn/trunk/html5.js’,array(),’1.5.1′);
    wp_enqueue_script(‘html5shiv’);
    $wp_scripts->add_data( ‘html5shiv’, ‘conditional’, ‘lt IE 9’ ); // DOES NOT WORK

    Need some expert help here to properly enqueue the scripts with conditional comments

Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘enqueue javascript js with conditional comments (for IE)’ is closed to new replies.
Skip to toolbar