Add js with custom type How can i add a script file with type='module', like this :

&lt;script src="site/test/test/index.js" type="module"&gt;&lt;/script&gt;


I tried with : 

  drupal_add_js(drupal_get_path('module', 'my_module') . '/assets/js/my_script.js', [
    'attributes' =&gt; ['type' =&gt; 'module'],
    'type' =&gt; 'module',
  ]);


But Drupal 7 only accept 'file', 'inline', 'external' or 'setting' as type.

Do you have any idea ?

Thanks.
You can do this in hook_preprocess_html():

function theme_preprocess_html(&amp;$var) {
  $script = [
    '#tag' =&gt; 'script',
    '#attributes' =&gt; [
      'type' =&gt; 'module',
      'src' =&gt; 'path/to/script.js',
    ],
    '#value' =&gt; '',
  ];
  drupal_add_html_head($script, 'script');  
}