DEFER or ASYNC allowed on a stylesheet include?

Doug picture Doug · Sep 17, 2014 · Viewed 50.1k times · Source

I know script files can use the DEFER and ASYNC keywords on a resource include. Do these keywords also work for stylesheet (i.e., CSS) includes?

Syntax would presumably be:

<link rel="stylesheet" type="text/css" href="./path/to/style.css" defer />

I just don't know if it's allowed or not.

Answer

fmsf picture fmsf · Sep 17, 2014

Defer and Async are specific attributes of the tag <script> https://developer.mozilla.org/en/docs/Web/HTML/Element/script

They will not work in other tags, because they don't exist there. A stylesheet is not a script that contains logic to be executed in parallel or after the loading. A stylesheet is a list of static styles that get applied atomically to html.