diff options
Diffstat (limited to 'devdocs/html/element%2Fscript%2Ftype.html')
| -rw-r--r-- | devdocs/html/element%2Fscript%2Ftype.html | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/devdocs/html/element%2Fscript%2Ftype.html b/devdocs/html/element%2Fscript%2Ftype.html new file mode 100644 index 00000000..45f928a6 --- /dev/null +++ b/devdocs/html/element%2Fscript%2Ftype.html @@ -0,0 +1,111 @@ +<header><h1><script>: type attribute</h1></header><div class="section-content"><p>The <code>type</code> attribute of the <a href="../script"><code><script></code></a> element indicates the <em>type</em> of script represented by the element: a classic script, an import map, a JavaScript module, speculation rules, or a data block.</p></div> +<h2 id="value">Value</h2> +<div class="section-content"> +<p>The value of this attribute indicates the type of data represented by the script, and will be one of the following:</p> <dl> <dt id="attribute_is_not_set_default_an_empty_string_or_a_javascript_mime_type"><a href="#attribute_is_not_set_default_an_empty_string_or_a_javascript_mime_type"><strong>Attribute is not set (default), an empty string, or a JavaScript MIME type</strong></a></dt> <dd> <p> Indicates that the script is a "classic script", containing JavaScript code. Authors are encouraged to omit the attribute if the script refers to JavaScript code rather than specify a MIME type. JavaScript MIME types are <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#textjavascript">listed in the IANA media types specification</a>. </p> </dd> <dt id="sect1"><a href="type/importmap"><code>importmap</code></a></dt> <dd> <p> This value indicates that the body of the element contains an import map. The import map is a JSON object that developers can use to control how the browser resolves module specifiers when importing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#importing_modules_using_import_maps">JavaScript modules</a>. </p> </dd> <dt id="module"><a href="#module"><code>module</code></a></dt> <dd> <p> This value causes the code to be treated as a JavaScript module. The processing of the script contents is deferred. The <code>charset</code> and <code>defer</code> attributes have no effect. For information on using <code>module</code>, see our <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">JavaScript modules</a> guide. Unlike classic scripts, module scripts require the use of the CORS protocol for cross-origin fetching. </p> </dd> <dt id="sect2"> +<a href="type/speculationrules"><code>speculationrules</code></a> <abbr class="icon icon-experimental" title="Experimental. Expect behavior to change in the future."> <span class="visually-hidden">Experimental</span> </abbr> +</dt> <dd> <p> This value indicates that the body of the element contains speculation rules. Speculation rules take the form of a JSON object that determine what resources should be prefetched or prerendered by the browser. This is part of the <a href="https://developer.mozilla.org/en-US/docs/Web/Performance/Speculative_loading#the_speculation_rules_api">speculation rules API</a>. </p> </dd> <dt id="any_other_value"><a href="#any_other_value"><strong>Any other value</strong></a></dt> <dd> <p> The embedded content is treated as a data block, and won't be processed by the browser. Developers must use a valid MIME type that is not a JavaScript MIME type to denote data blocks. All of the other attributes will be ignored, including the <code>src</code> attribute. </p> </dd> </dl> <div class="notecard note" id="sect3"> <p><strong>Note:</strong> In earlier browsers, the type identified the scripting language of the embedded or imported (via the <code>src</code> attribute) code.</p> </div> +</div> +<h2 id="specifications">Specifications</h2> +<div class="notecard warning"> +<strong>No specification found</strong><p>No specification data found for <code>html.elements.script.type</code>.<br><a href="#on-github">Check for problems with this page</a> or contribute a missing <code>spec_url</code> to <a href="https://github.com/mdn/browser-compat-data">mdn/browser-compat-data</a>. Also make sure the specification is included in <a href="https://github.com/w3c/browser-specs">w3c/browser-specs</a>.</p> +</div> +<h2 id="browser_compatibility">Browser compatibility</h2> +<div class="_table"><table> +<thead> +<tr id="bct-browser-type"> +<th></th> +<th colspan="6">Desktop</th> +<th colspan="6">Mobile</th> +</tr> +<tr id="bct-browsers"> +<th></th> +<th>Chrome</th> +<th>Edge</th> +<th>Firefox</th> +<th>Internet Explorer</th> +<th>Opera</th> +<th>Safari</th> +<th>WebView Android</th> +<th>Chrome Android</th> +<th>Firefox for Android</th> +<th>Opera Android</th> +<th>Safari on IOS</th> +<th>Samsung Internet</th> +</tr> +</thead> +<tbody> +<tr> +<th><code>type</code></th> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">12</td> +<td class="bc-supports-yes">1</td> +<td class="bc-supports-yes">Yes</td> +<td class="bc-supports-yes">15</td> +<td class="bc-supports-yes">≤4</td> +<td class="bc-supports-yes">4.4</td> +<td class="bc-supports-yes">18</td> +<td class="bc-supports-yes">4</td> +<td class="bc-supports-yes">14</td> +<td class="bc-supports-yes">≤3.2</td> +<td class="bc-supports-yes">1.0</td> +</tr> +<tr> +<th><code>importmap</code></th> +<td class="bc-supports-yes">89</td> +<td class="bc-supports-yes">89</td> +<td class="bc-supports-yes">108</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">75</td> +<td class="bc-supports-yes">16.4</td> +<td class="bc-supports-yes">89</td> +<td class="bc-supports-yes">89</td> +<td class="bc-supports-yes">108</td> +<td class="bc-supports-yes">63</td> +<td class="bc-supports-yes">16.4</td> +<td class="bc-supports-yes">15.0</td> +</tr> +<tr> +<th><code>module</code></th> +<td class="bc-supports-yes"><details><summary>61</summary>Module scripts without the <code>async</code> attribute do not load when the page is served as XHTML (<code>application/xhtml+xml</code>). See <a href="https://crbug.com/717643">bug 717643</a>.</details></td> +<td class="bc-supports-yes"> +<details><summary>79</summary>Module scripts without the <code>async</code> attribute do not load when the page is served as XHTML (<code>application/xhtml+xml</code>). See <a href="https://crbug.com/717643">bug 717643</a>.</details>16–79</td> +<td class="bc-supports-yes">60</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes"><details><summary>48</summary>Module scripts without the <code>async</code> attribute do not load when the page is served as XHTML (<code>application/xhtml+xml</code>). See <a href="https://crbug.com/717643">bug 717643</a>.</details></td> +<td class="bc-supports-yes"><details><summary>10.1</summary>Module scripts do not load when the page is served as XHTML (<code>application/xhtml+xml</code>).</details></td> +<td class="bc-supports-yes"><details><summary>61</summary>Module scripts without the <code>async</code> attribute do not load when the page is served as XHTML (<code>application/xhtml+xml</code>). See <a href="https://crbug.com/717643">bug 717643</a>.</details></td> +<td class="bc-supports-yes"><details><summary>61</summary>Module scripts without the <code>async</code> attribute do not load when the page is served as XHTML (<code>application/xhtml+xml</code>). See <a href="https://crbug.com/717643">bug 717643</a>.</details></td> +<td class="bc-supports-yes">60</td> +<td class="bc-supports-yes"><details><summary>45</summary>Module scripts without the <code>async</code> attribute do not load when the page is served as XHTML (<code>application/xhtml+xml</code>). See <a href="https://crbug.com/717643">bug 717643</a>.</details></td> +<td class="bc-supports-yes"><details><summary>10.3</summary>Module scripts do not load when the page is served as XHTML (<code>application/xhtml+xml</code>).</details></td> +<td class="bc-supports-yes"><details><summary>8.0</summary>Module scripts without the <code>async</code> attribute do not load when the page is served as XHTML (<code>application/xhtml+xml</code>). See <a href="https://crbug.com/717643">bug 717643</a>.</details></td> +</tr> +<tr> +<th><code>speculationrules</code></th> +<td class="bc-supports-yes">109<details><summary>105</summary>Initial support included same-origin prerendering only.</details> +</td> +<td class="bc-supports-yes">109<details><summary>105</summary>Initial support included same-origin prerendering only.</details> +</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">95<details><summary>91</summary>Initial support included same-origin prerendering only.</details> +</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">109<details><summary>103</summary>Initial support included same-origin prerendering only.</details> +</td> +<td class="bc-supports-yes">109<details><summary>103</summary>Initial support included same-origin prerendering only.</details> +</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">74<details><summary>71</summary>Initial support included same-origin prerendering only.</details> +</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">21.0<details><summary>20.0</summary>Initial support included same-origin prerendering only.</details> +</td> +</tr> +</tbody> +</table></div><div class="_attribution"> + <p class="_attribution-p"> + © 2005–2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br> + <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type</a> + </p> +</div> |
