5

I'm just wondering why don't you guys compile all the cpresources into 1 .js and 1 .css file?

Right now this folder is gigantic :D cfr: https://i.stack.imgur.com/UixpA.png

1 Answer 1

9

Craft CMS 3 uses Yii2 Asset Bundles for AdminCP resources. This lets it handle dependencies such as certain scripts not loading before jQuery, for example.

Remember that many Craft CMS 3 components need to publish JS/CSS resources to work, as do third party plugins. Some system needs to manage these things, and their dependencies.

Combining it all into one isn’t practical, since different pages require different resources, and plugins may add resources in arbitrarily. If you really did combine everything needed for the AdminCP backend, it’d be slow to build (and that build would have to be done dynamically as other components add/remove resources), and not very useful, especially with http/2 and multiple streams.

Note that the way it works now is a vast improvement over Craft 2.x, where every AdminCP static resource request went through the index.php, and this was slow to load, and could not be cached.

Just ignore the cpresources/ directory; consider it a cache that you don't need to worry about.

2
  • Ok thnx for the explanation! One more thing, you said "Just ignore the cpresources/ directory; consider it a cache that you don't need to worry about.". Does this mean we can just delete this folder and the files will be recreated automagicly?
    – Kobe Aerts
    Mar 18, 2018 at 17:30
  • 1
    Yes, you can delete the folder and it will be recreated automagically. Mar 18, 2018 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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