With version 2.3.0, Magento includes about 200 internal PHP packages (in the “magento” namespace) plus more than a hundred external PHP packages. These numbers have grown a lot in the last few releases, especially with several packages for the GraphQL integration and for the Multi Source Inventory. Since the average Magento 2 project doesn’t need all those modules, wouldn’t it be great to get rid of some unused modules?

I have written about how you can remove unused core modules before, including suggestions on what modules can be removed in Magento 2.2. At the recent Magento Hackathon in Bremen, Germany, one of the groups chose the topic “Make Magento small again” with the goal to reduce the number of dependencies between modules in order to be able to remove as many modules as possible.

Benefits of removing core modules

  • Less code means less maintenance work
  • Removed code is debugged code
  • Fewer security risks
  • Magento becomes faster with certain modules disabled (especially the Magento_Swatches module, see our blog post about performance improvements)

Risks of removing core modules

  • Dependencies may not be declared correctly, so you might actually remove code which is needed by another module.
  • You might need some of the removed functionality as it’s not always clear which module contains which functionalities.

The Approach

It’s preferred to remove modules via composer. Add a block as follows to your composer.json file:

After that, call composer update. The modules will be removed from the code base.

Ideally, you remove modules before installing Magento in your project. Otherwise, the installation will create some module specific tables in your database which will be obsolete after removing the corresponding modules.

Selection of modules

It’s up to you which modules to remove. Here, we present a suggestion, but using it is on your own risk. Of course, you can re-add the modules you need in your project. For example:

  • If you use Swatches, enable magento/module-swatches and magento/module-swatches-layered-navigation.
  • If you’d like to use the Multi Source Inventory (MSI), don’t remove the modules starting with magento/module-inventory.
  • If you use ImportExport for your interfaces, don’t remove magento/module-*-import-export.

Suggestion for Magento 2.3.0:

Please look through the list in detail before using it.
There are no declared dependencies from any leftover core modules to the modules which are suggested to remove here, but there are dependencies between these removed modules. So if you re-add selected modules, you might need to re-add their dependencies too. Have a look at the module’s composer.json if you are unsure about their dependencies.

Work in Progress

If you look at the list above, you can see that two modules are not included:

  • magento/module-import-export
  • magento/module-catalog-import-export

That is because there are dependencies declared from the Magento_CatalogUrlRewrite module to those two – dependencies which shouldn’t be there in my opinion, because the Magento_CatalogUrlRewrite module will work flawlessly even without the ImportExport modules. It just adds two Observers which will never be instantiated if the ImportExport modules are not available. I have created a Pull Request to Magento about this issue – let’s see what the core engineers’ opinion is on this case.

Conclusion

If you don’t need them, you can remove up to half of the Magento 2 core modules and most external Magento 2 modules. But please take care before and during the removal – some of the code might actually be used, so test it thoroughly. Using the above suggestions is at your own risk.

Update May 2019

We removed some modules which have to do with message queues from the list as they are reported to cause problems with the REST API. Thanks Oleksandr Lyzun for reporting!

Andreas von Studnitz

Author: Andreas von Studnitz

Andreas von Studnitz is a Magento developer and one of the Managing Directors at integer_net. His main areas of interest are backend development, Magento consulting and giving developer trainings. He is a Magento 2 Certified Developer Plus and a Magento (1 and 2) Certified Solution Specialist. He was appointed a Magento Master in 2019.

More Information · Twitter · GitHub · LinkedIn