Preload Onload Polyfill
A <link rel="preload">
Polyfill. Call the onload event, also in unsupported Browser.
Usage
npm install js.polyfill.preload.onload
Module (src)
; const preload = ;preload || preload;
Compiled (dist)
Inject the Polyfill into <head>
within a <script>
element.
Note: The Polyfill should be injected inline to save the extra request.
Example
Inline Critical CSS and <link rel="preload">
injected main Stylesheet. With noscript fallback and Polyfill to support browser who don't understand rel=preload
.
Note: This Example is also used within the dev environment. Run npm start
from the repository main directory and open http://localhost:8090
in your Browser.
<head>
Inline (critical) Style in
<head>
Injected preload style css/style.css in
Note: This style is also injected as fallback within the <noscript>
element in <head>
.
Support
The Polyfill enable <link rel="preload"> support (e.g. for stylesheets) in browser (e.g. Firefox or IE11) which currently not support this
` attribute.
Tested with MSIE 11, Edge 17, Firefox 60 and Chrome 72.