The as attribute on a <link> tells the browser what kind of resource a preload (or modulepreload) will fetch — for example script, style, font, or image.
It is required with rel="preload" and optional with rel="modulepreload" (defaults to script). Pair it with href, and often type or crossorigin. See also rel.
Baseline · Widely available.
Not deprecated. Stable with rel="preload" across modern browsers (widely available since about January 2021).
Preload ≠ execute.
as="script" only downloads early. You still need a <script> (or dynamic insert) to run the file. For modules, prefer rel="modulepreload".
Syntax
HTML Syntax
syntax.html
<link rel="preload" href="…" as="resource_type">
resource_type is a destination keyword such as script, style, font, or image.
Values
Attribute Values
Common as values for rel="preload" (MDN / HTML destinations):
Value
Description
Try it
style
CSS stylesheet (also used later via rel="stylesheet")
Most preload bugs come from a missing as, wrong CORS mode, or unused downloads.
required
Omit as and preload may do nothing
For rel="preload", as is required. Without it, many browsers will not fetch the resource.
CORS
font and fetch need crossorigin
Mismatch causes a second download or a wasted preload. Match the real request’s credentials mode.
waste
Do not preload everything
Unused preloads compete for bandwidth. Preload only critical, soon-used assets.
scope
Not for every rel
Skip as on normal stylesheet, icon, or canonical links. It belongs with preload / modulepreload.
modules
Prefer modulepreload for ES modules
rel="modulepreload" fetches, parses, and fills the module map. as is optional there (default script).
Compatibility
Browser Support
as is an HTML attribute on <link> for preload destinations. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
as
Widely available with rel="preload" since about January 2021. Desktop Chrome, Firefox, Safari, Edge, and Opera support the common destinations.
95%Global support (approx.)
Google Chrome50+
Full support
Mozilla Firefox56+
Full support
Apple Safari11.1+
Full support
Microsoft Edge79+
Full support
Opera37+
Full support
Samsung InternetModern
Full support
Internet ExplorerNo
Not supported
as (with preload)Widely supported
Bottom line: Safe to use for critical early fetches. Always set as with preload, and add crossorigin for fonts and fetch.
Remember
Key Takeaways
Role: name the preload destination — script, style, font, image, …
Required on rel="preload"; optional on modulepreload.
CORS:font and fetch need matching crossorigin.
Hint only: preload caches early — it does not apply CSS or run JS by itself.
One line:as tells preload what you are fetching — required for correct priority, headers, and cache reuse.
Frequently Asked Questions
On a link with rel="preload" (or optionally modulepreload), as tells the browser what kind of resource is being fetched — script, style, font, image, and so on — so it can set priority, Accept headers, and CSP correctly.
Yes for rel="preload". Without as, the preload often will not fetch. For rel="modulepreload", as is optional and defaults to script.
The link element, mainly with rel="preload" or rel="modulepreload". Do not set as on ordinary stylesheet or icon links.
Font (and fetch) preloads must use CORS mode that matches the real request. Add crossorigin on the preload link or the font may download twice or fail to reuse the cache.
No. rel="preload" as="script" only downloads and caches the file. You still need a script tag (or dynamic insert) to run it.
No. It is part of modern resource hints and is Baseline widely available with preload.