Skip to content
Order assets (read: css tags) explicitly with an order attribute
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Config/Dom Move UrnResolver to correct location Dec 14, 2018
Model Whitespace etc cleanup Nov 19, 2018
View Fix Issue #11 - Implement MergeableInterface a child of LocalInterface Aug 7, 2019
.gitignore Ignore c9 files Nov 19, 2018
LICENSE Move files Apr 17, 2016 Add notes on how to run the unit tests Nov 20, 2018
phpunit.xml Add notes on how to run the unit tests Nov 20, 2018
registration.php Rearrange for composer Sep 8, 2016


Order assets (read: css tags) explicitly with an order attribute

Magento2 has no way to order assets out of the box. This extension allows you to specify an order attribute in css tags in layout XML files and layout updates in the admin UI.



composer require quickshiftin/assetorderer


Download the repository and add it in your Magento2 installation under app/code/Quickshiftin/Assetorderer

Magento commands

Once you've installed the code via composer or download, you need to run some Magento commands:

  • bin/magento module:enable Quickshiftin_Assetorderer
  • bin/magento setup:upgrade
  • rm -rf var/cache var/di var/generation var/page_cache && bin/magento setup:di:compile


Suppose you want to add a custom CSS file, css/home.css, on your homepage. Ordinarilly you would enter this in the layout update editor

<css src="css/home.css"/>

However, Magento most likely will place the generated link tag before the base CSS file, thus not honoring the cascade. With the extension installed you can enter the css tag with an arbitrary order attribute like so

<css src="css/home.css" order="100" />

Any tags without an explicit order will come as they appear normally (effectively treated like they have an order of 1).

Unit Tests

To run the unit tests, in a working installation of Magento2, with the extension enabled

  • cp vendor/quickshiftin/assetorderer/phpunit.xml dev/tests/unit
  • cd dev/tests/unit
  • php ../../../vendor/phpunit/phpunit/phpunit
You can’t perform that action at this time.