Preload CSS file not supported on Firefox and Safari Mac

前端 未结 7 1797
日久生厌
日久生厌 2020-12-16 14:23

I added the attribute rel=\"preload\" to all css links like this :

   

        
相关标签:
7条回答
  • 2020-12-16 15:15

    Reliably preload across browsers with loadCSS

    One issue with preloading is that it is not supported by browsers like Firefox and Internet Explorer (as of Nov 2018). As a result, these browsers will not download the CSS file and this can result into serious display issues for your web-pages. This makes it critical to include a JavaScript polyfill for preload - loadCSS.

    • Download the loadCSS JavaScript file or simply copy it’s JS code from here.
    • Load the loadCSS polyfill wherever CSS stylesheet preload is performed:

    <style>
    [Your critical CSS goes here]
    </style>
    
    
    <!– Reliably defer loading of non-critical CSS with loadCSS–>
    <link rel=“preload” href=”[yourcssfile]” as=“style” onload=“this.onload=null; this.rel=‘stylesheet’”>
    <noscript><link rel=“stylesheet” href=”[yourcssfile]” ></noscript>
    
    
    
    <!– Inline the loadCSS preload polyfill code or load it via external JS file–>
    <script src=“./cssrelpreload.js”></script>

    0 讨论(0)
提交回复
热议问题