I'm trying to load CSS files async, I've managed to load all the JS async by adding the param async to some xml files but I do not find where do I need to change the xml files.
|
There is a way to do this that is not completely backwardly compatible (IE doesn't support it, and it comes with downsides). In short, you need to do the following:
Most modern browsers will async the CSS for one of the previous two preconditions. However, this is probably not desirable. There are downsides:
Best of luck! |
|||||
|
There is no de facto way of loading css async "out the box" without using some kind of js loader to do it. http://codepen.io/Tigt/post/async-css-without-javascript is an excellent article on this subject but the long and short of it is you would need to add a new block before the footer that either allows css to be added directly or through a javascript loader. |
|||
|
I am implementing this right now, using https://github.com/filamentgroup/loadCSS. Split CSS into initial CSS and async CSSMy site runs the Magento RWD theme. Stylesheets are edited in SCSS and compiled to one file,
Installation of loadCSS.js
Including loadCSS in themeIn
Calling loadCSSAt the beginning of
Although it would make more sense to inline this in the HTML head, as shown below. That way, the browser has one less HTTP request it needs to make. A more systematic approachA better implementation of this would be to create a new method, A more systematic approach that doesn't include making a moduleWe can probably do even better and do this in a new block template stored in Yet another improvement: Follow Filament Group's RecommendationThis is probably as close as we can get to a correct way, until a standard for asynchronous CSS has been established. From http://filamentgroup.github.io/loadCSS/test/preload.html:
In the example, The ideal Magento-based solutionwould be a module that implements the above with two new method calls, |
||||
|