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

Shan Atif
1471 silver badge14 bronze badges
asked Jun 2, 2019 at 15:39
2
  • 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. Commented 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. Thanks Commented Jun 3, 2019 at 8:04

1 Answer 1

0

You need to include css file in "default_head_block.xml" file see the example below:

<css src="Vendor_Module::css/filename.css"/>
answered Jun 3, 2019 at 5:30
1
  • 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 Commented Jun 3, 2019 at 8:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.