Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

In Drupal 8 the drupal_add_js() function $options parameter now also supports a browsers option just like drupal_add_css(). This allows JavaScript to be wrapped in conditional comments. Example:

drupal_add_js($some_path . '/file.js', array('browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE))); ?>

Outputs:

<!--[if lte IE 8]>
<script type="text/javascript" src="http://example.com/some/path/file.js"></script>
<![endif]-->
Impacts: 
Module developers
Themers

Comments

sam moore’s picture

Any chance of a backport for this? Sorry if I'm asking in the wrong place.