HTML Script - 2 Tags and its Attributes (Reference)

Tech:
Html
Since:
1 year ago
Views:
2

Html script tags are used to embed scripts in html. It is mainly used to embed javascript files. The script tags can have attributes like src, type, async, defer, charset, crossorigin, integrity, and nonce.

Script tags:

<script>

Defines a client-side executable code. By Default, Html parse until js file, then download and execute and resume. By Using Async attribute, Html parse and continue to download js files ,and stop only while js execution By using Defer attribute, Html parse and continue to download js files and finish parsing and then start js execution

<script src="URL_to_js_file"></script>

<script>
  // Javascript code
</script>


<!-- Attributes - async, charset, defer, src, type, crossorigin, integrity, nonce. -->

<noscript>

Defines an alternate content if browser does not support client-side scripts.

<script>
  // Javascript code
</script>
<noscript>Your browser does not support JavaScript!</noscript>