Languages
[Edit]
EN

HTML - load CSS file in async mode

6 points
Created by:
Kate_C
23360

In this short article, we would like to show how to load CSS files asynchronously in HTML.

Quick solution:

<link rel="stylesheet" href="/path/to/style.css" media="only x" onload="this.media='all'">

 

Practical example

When the style file is loaded, media rule is changed to all devices, causing displaying loaded style.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <link rel="stylesheet" href="/path/to/style.css" media="only x" onload="this.media='all'">
</head>
<body>
  Web page content here...
</body>
</html>
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join