import-css
Load CSS asynchronously without render blocking in the given order.
Install
npm i -S import-css# or yarn add import-css
About
import-css
contains 2 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-in-body.js
also uses<link>
tag, but this variant a little lighter thanlink.js
because of restricted to use only in<body>
.
Also exist *-async.js
variants of both files, where you can import CSS outside of queue.
API
importCSS(String url, String media)
Files: link.js
, link-in-body.js
importCSS(String url, String media, Boolean async)
Files: link-async.js
, link-in-body-async.js
Examples
critical css
section.css
footer.css
index.html
with link.js
Header Section Footer