1

(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 Jun 3 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. Thanks – Richard Laws Jun 3 at 8:04
0

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. Thanks – Richard Laws Jun 3 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.