Yahoo India Web Search

Search results

  1. The <script> tag is used to embed a client-side script (JavaScript). The <script> element either contains scripting statements, or it points to an external script file through the src attribute. Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.

    • HTML JavaScript

      The HTML <script> tag is used to define a client-side script...

    • Overview
    • Attributes
    • Notes
    • Examples
    • Browser compatibility
    • See also

    This element includes the global attributes.

    async

    For classic scripts, if the async attribute is present, then the classic script will be fetched in parallel to parsing and evaluated as soon as it is available.

    For module scripts, if the async attribute is present then the scripts and all their dependencies will be fetched in parallel to parsing and evaluated as soon as they are available.

    This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. defer has a similar effect in this case.

    This is a boolean attribute: the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

    Scripts without async, defer or type="module" attributes, as well as inline scripts without the type="module" attribute, are fetched and executed immediately before the browser continues to parse the page.

    The script should be served with the text/javascript MIME type, but browsers are lenient and only block them if the script is served with an image type (image/*), a video type (video/*), an audio type (audio/*), or text/csv. If the script is blocked, an error event is sent to the element; otherwise, a load event is sent.

    Basic usage

    These examples show how to import (an external) script using the

    Module fallback

    Browsers that support the module value for the type attribute ignore any script with a nomodule attribute. That enables you to use module scripts while providing nomodule-marked fallback scripts for non-supporting browsers.

    Importing modules with importmap

    When importing modules in scripts, if you don't use the type=importmap feature, then each module must be imported using a module specifier that is either an absolute or relative URL. In the example below, the first module specifier ("./shapes/square.js") resolves relative to the base URL of the document, while the second is an absolute URL. An import map allows you to provide a mapping that, if matched, can replace the text in the module specifier. The import map below defines keys square and circle that can be used as aliases for the module specifiers shown above. This allows us to import modules using names in the module specifier (rather than absolute or relative URLs). For more examples of what you can do with import maps, see the Importing modules using import maps section in the JavaScript modules guide.

    BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

    •document.currentScript

    •Flavio Copes' article on loading JavaScript efficiently and explaining the differences between async and defer

  2. Dec 13, 2023 · Learn how to use the HTML tag to embed client-side scripts in your web pages. See syntax, attributes, examples, and supported browsers for this tag.

  3. Learn how to use the HTML script tag to embed JavaScript or other scripting languages in an HTML page. See examples, attributes, and best practices for loading and executing scripts.

  4. Sep 25, 2023 · Learn how to use the HTML tag to embed or reference JavaScript code in your web pages. Explore the attributes, examples, and common mistakes of this powerful HTML tag.

  5. www.w3docs.com › learn-html › html-script-tagHTML <script> Tag - W3docs

    Learn how to use the HTML tag to embed or link JavaScript scripts in an HTML document. See syntax, attributes, examples and browser support for the tag.

  6. People also ask

  1. People also search for