Magento – Does magento2 use r.js optimization for require.js when deploying static files

javascriptmagento2optimizationrequirejs

I see that javascript contributes a lot to my magento2 page weight (1 mb).

I wonder if it could be optimized with r.js when deploying static content or magento2 already uses an optimization tool.

Does anyone have any experience with that?

Best Answer

Yes. It could be optimized by using r.js

  • Anton Krill showed a basic implementation here https://github.com/antonkril/magento-rjs-config - however Magento team is working on new external bundling solution - but I guess it will still take some time
  • Shane Osbourne from JH is using r.js with their own way implementation in Magento 2 projects - he created config-gen tool to help devs create build.js file for requirejs optimizer to create bundles - https://github.com/WeareJH/config-gen
Related Topic