YouTip LogoYouTip

Att Script Async

# HTML ``` --- ## Definition and Usage When a browser encounters a standard ` ``` ### XHTML Compatibility In XHTML, attribute minimization is forbidden. You must define the attribute with its full value: ```html ``` --- ## Code Examples ### 1. Basic Asynchronous Script Loading Use `async` for independent third-party scripts (like analytics, trackers, or ads) that do not depend on other scripts and do not manipulate the DOM structure directly. ```html Async Script Example

Welcome to YouTip

The page content will load smoothly without waiting for the analytics script to download.

``` ### 2. Handling Dependencies (When NOT to use Async) If your scripts depend on each other, do **not** use `async`. For example, if `main.js` depends on `jquery.js`, using `async` on both might cause `main.js` to execute first, resulting in a `"$" is not defined` error: ```html ``` **Correct Approach for Dependent Scripts:** Use `defer` instead. This ensures both scripts load asynchronously but execute in the exact order they are defined: ```html ``` --- ## Browser Support | Feature | Chrome | Edge / IE | Firefox | Safari | Opera | | :--- | :--- | :--- | :--- | :--- | :--- | | **`async` Attribute** | Yes | Yes (IE 10+) | Yes | Yes | Yes | *Note: Internet Explorer 9 and earlier versions do not support the `async` attribute.*
← Att Script CharsetAtt Option Disabled β†’