The uncached load time of the homepage of a local Magento 2.1.5 shop dropped from 4.5 seconds to 2.6 seconds on average after I disabled all Magento 2 core modules which could be disabled. Disclaimer: Measurements were done with disabled caches and activated developer mode on my local machine.

Even though most pages will be delivered cached, there will always be requests where only parts of the pages can be cached. The general performance increase won’t be 40% on a live server, but it will still be noticeable. And during development, when cache is being cleared frequently, it makes a huge difference.

That should be reason enough to disable as many modules as possible, right?

As an additional benefit, the admin users won’t get distracted by configuration options and features which aren’t used in your project.

What did I do?

Magento 2 brings a mechanism to disable single modules, including core modules. You can do that using the integrated command line tool. The call could look like this:

Many core modules of Magento 2 cannot be disabled – you will get an error message because other modules depend on that module if you try to disable them. So I created a small tool which helps me find out which modules can be disabled easily.

New command line tool: info:dependencies:show-removable

You can find the module containing the new command on GitHub: https://github.com/avstudnitz/AvS_DisableModules/.
You can install the module via composer (“avstudnitz/disable-modules”) or by dropping the content of the repository into app/code/AvS/DisableModules/. More detailed installation instructed are provided on the GitHub page.

After installation, you’ll have a new command available:

This will give you an output like this:

The file modules-removable.csv contains content like this:

All those files can be safely deleted. Add the following code in front of each line and paste it into the shell:

After you have disabled the modules, you can do a second run – new modules might show up which can now be disabled as they were only required by modules which you have just disabled.

Which modules should be disabled?

In a default Magento 2.1.5 CE installation, the following modules can be disabled – in some cases only after other modules from the list have been disabled:

First rule: Don’t disable any modules whose functionality you need! (Obviously)
Second rule: Don’t rely on Magento’s modularity. This means: there may be hidden dependencies.

Hidden Dependencies

Dependencies are declared in the composer.json file of each module. This is a manual process – in some cases, not all dependencies have been declared by the Magento core team. A module might still require another module even if it doesn’t say so.

In our recent project, we disabled Magento_ConfigurableProduct as we were using Grouped Products and Simple Products only. At first, it looked okay, but then we got an error during indexing which led us to the conclusion that the indexer has a hidden dependency to the Configurable Products module.

So: Try out if everything (still) works in your project and observe the behaviour. If you have automatic tests available: perfect, they help you find hidden dependencies much faster.

Practical Example

In our current project, we disabled about 30 modules, which works out well so far. This is the list of modules, those which are disabled are marked with a “0” (from app/etc/config.php):

Project specific modules have been stripped from the list. Feel free to take this module list as a starting point for your module.

Conclusion

Magento 2 is a big step forward regarding modularity, compared to Magento 1. On the other hand, some work still has to be done for even better modularity.
You can gain a much better performance by disabling the right modules. But be careful: some modules might be needed even if you don’t recognize that on first sight. Personally, I will start off new projects by disabling unneeded modules first from now on.

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 Certified Developer since 2011 (and 2018 for Magento 2) and a Magento Certified Solution Specialist since 2014 (Magento 1) respective 2017 (Magento 2).

More Information · Twitter · GitHub · LinkedIn