3

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.imgur.com/Oksr5Kn.png

6

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.

  • 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 '18 at 17:30
  • 1
    Yes, you can delete the folder and it will be recreated automagically. – Marion Newlevant Mar 18 '18 at 21:32

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.