<script>
tag is intended to include script and data blocks into a HTML documnet, not to store content which is (directly) rendered for the user. <script>
element are src | Address (URL?) of the script |
type | empty, or module : a JavaScript module, or importmap : an import map. Any other value interprets the script as an (unprocessed) data block. |
nomodule | A boolean attribute that allows to prevent a script from being executed in user agents that support module scripts. |
async | A boolean attribute to execute the script as soon as it is available |
defer | A boolean attribute to defer execution |
crossorigin | A CORS setting attribute. |
integrity | |
referrerpolicy |
src
attribute must be set to the URL where that resource is located. type
attribute specifies the kind of the script. text/javascript
. text/javascript
: default application/ld+json
: See JSON-LD text/ecmascript
application/ecmascript
application/javascript
type="module"
specifies the script to be a JavaScript module script. import
declaration defer
and async
are boolean attributes. async
causes the script to be fetched in parallel and to be parsed and executed as soon as possible (sometimes even before parsing is complete)
defer
causes the script to be fetched in parallel and to be evaluated when is finished parsing.
src
attribute is present.
defer
, but not async
, both attributes can be specified. In this case, it behaves as if only defer
was specified. defer
has no effect
<script>
tag to define inline or external JavaScript code. <script>
tag to specify the source code for WebGL. <noscript>
tag. document.scripts
document.currentScript
returns the currently running <script>
tag (which is not a JavaScript module). <script>
element in the living standard.