1

Is there a way to order the CSS assets in Magento 2.2?

I want to include https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css Bootstrap's CSS before styles-m and styles-l css files.

I'm not seeing where to do this at, though. Seems like the most basic thing in the world of web design / web dev. Any ideas?

3

There is no way to accurately change the load order for CSS without using a third party module or making changes yourself.

If you want to load your CSS after the default then some people report this works:

<css src="css/your-file.css" media="all"/>

So you can load your CSS after the default, but if you add more CSS you can't order them all as you want.

Adding any attribute will add your CSS after the core CSS, which is why some people think order="100" works, but this isn't the case. This answer goes into more detail.

  • 2 years later and there is still no way even though this is a must have – Black Mar 6 '20 at 17:00
  • 1
    I lost faith in Magento's frontend many years ago so I had no expectation they would ever add this functionality :( – Ben Crook Mar 6 '20 at 17:24

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