(Magento 2.1.4) I am trying to add my 'above the fold' CSS in to the <head> section.
I know I can add it in via Content> Configuration> HTML Head however the issue with this is that it loads it AFTER the merged/minified deployed CSS files.
I've tried just putting <style>CSS</style> in to my default_head_block.xml but that doesn't work. And as far as I can tell you can't put a block in to this XML (I might be wrong though)
What is the best method?
Thanks
-
you cant directly put a style tag in default_head_block, I think the best way is to add your custom css as a separate css file.fmsthird– fmsthird2019年06月03日 02:36:17 +00:00Commented Jun 3, 2019 at 2:36
-
Is there then anyway to move the other CSS files in the head to the bottom of the page? Basically I am try to load my 'above the fold' CSS first to comply with google pagespeed. ThanksRichard Laws– Richard Laws2019年06月03日 08:04:50 +00:00Commented Jun 3, 2019 at 8:04
1 Answer 1
You need to include css file in "default_head_block.xml" file see the example below:
<css src="Vendor_Module::css/filename.css"/>
-
thanks but is there then anyway to move the other CSS files in the head to the bottom of the page? Basically I am try to load my 'above the fold' CSS first to comply with google pagespeed. ThanksRichard Laws– Richard Laws2019年06月03日 08:05:04 +00:00Commented Jun 3, 2019 at 8:05