Load CSS asynchronously without render blocking.
Install with npm
npm i import-css
or
yarn add import-css
import-css
contains 3 variants of importCSS
function
-
link.js
variant uses<link>
tag. If you want to import multiple styles for "progressive loading" recommended move all function calls before</body>
. -
link-and-body.js
also uses<link>
tag, but this variant a little lighter thanlink.js
because of restricted to use only in<body>
. -
xhr.js
obviously uses XMLHttpRequest to load styles. For earlier loading start recommended to call this function only in<head>
.xhr.js
variant loads styles fully async and more faster (if started at<head>
). But with<link>
variant you have possibilities to include styles from other hosts without CORS. In IE and Edgexhr.js
loads styles in parallel unlike<link>
variants.