This is the same as https://www.drupal.org/project/drupal/issues/1664602 > ## Problem/Motivation > Currently there is no way to pass `#attributes` to the `drupal_add_js()` function. This is not a feature that is widely used, however, there are unique cases where the `` tag generated needs to have available an `id=""` or other unique attributes to that tag. > > ## Proposed resolution > By initializing the `#attributes` key of the `$js_element` array we can easily pass specific `#attribute` elements in our `drupal_add_js()` calls, and since `theme('html_tag', array('element' => $js_element));` handles `#attributes` passed to it, all additional support is inherited. Here is an example of the new attribute code working in the case 'external' type of `drupal_add_js()` is invoked. The patch of course accounts for all cases of `'type'`: ```php case 'external': $js_element = $element; // Attach custom attributes to the element. $js_element['#attributes'] = !empty($item['attributes']) ? $item['attributes'] : array(); // Preprocessing for external JavaScript files is ignored. if ($item['defer']) { $js_element['#attributes']['defer'] = 'defer'; } $js_element['#attributes']['src'] = $item['data']; $processed[$index++] = theme('html_tag', array('element' => $js_element)); break; ```
GitHub Issue #: 
5478