There is a standard task - to optimize the loading of CSS.
There is a snare ( /static/CACHE/css/1f37a94c2ab5.css) and there are a couple of fonts that are loaded from the outside.
With fonts, I decided this:
<noscript id="deferred-styles"> <link type="text/css" rel="stylesheet" href="{% static 'css/pe-icon-7-stroke.css' %}"> <link type="text/css" rel="stylesheet" href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" integrity="sha384-dNpIIXE8U05kAbPhy3G1cz+yZmTzA6CY8Vg/u2L9xRnHjJiAK76m2BIEaSEV+/aU" crossorigin="anonymous"> <link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Pacifico" > <link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,300,500,700"> </noscript> and this script:
<script> var loadDeferredStyles = function() { var addStylesNode = document.getElementById("deferred-styles"); var replacement = document.createElement("div"); replacement.innerHTML = addStylesNode.textContent; document.body.appendChild(replacement) addStylesNode.parentElement.removeChild(addStylesNode); }; var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame; if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); }); else window.addEventListener('load', loadDeferredStyles); </script> But this did not solve the problem. PageSpeed Insights swears at the file, because it is not processed by this script.
But if I shove and shrink CSS in <noscript></noscript> , then all CSS connections will be cursed, and there is an obvious problem with drawing styles - first a white html page without styles is loaded, and then the drawing takes place.
Tell me how to solve it correctly?
Thank you in advance.
styletags the critical one for displaying the first 1000px css page. You can generate it for example by this service jonassebastianohlsson.com/criticalpathcssgenerator - Andrey Fedorov