Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughHow to Remove Unused Modules in Drupal 8
One of the important aspects of keeping your Drupal 8 site up-to-date, secure and performing well is to remove unused modules.
There are a number of reasons why you would want to do this:
- Security - Every module should be kept up-to-date. If you're not using a particular feature, you're just giving yourself more work to do.
- Performance - Drupal is an event-based CMS so at every point in the page-build process, Drupal is checking to see if any module on your site wants to do something. All of this adds up!
- Site clutter - The "Extend" menu is long enough! Not to mention any configuration menu items that a module might add.
- Fluff - Some modules just don't belong - Some development modules such as Devel should never be on a production server. It's always best to remove those completely.
Step 1: Uninstall
When you install a module on your site, depending on the module, a number of things happen. Obviously the code is added to the /modules folder. However, if that module stores data in the database, then tables are created and sample data may be installed. It's important to uninstall a module before you remove the code so the module's uninstall configuration file can perform it's tasks.
It's also worthy to note that if you simply delete the code without uninstalling, you might encounter a huge performance regression which stems from Drupal recursively searching through the site for the "missing" module on every page load.
Caution: When you uninstall a module that does write data to the database, all your data will be deleted.
To uninstall a module:
- Log into your Drupal site and click on Extend -> Uninstall
- Find the module you wish to uninstall and put a checkmark in the box.
- Scroll down to the bottom of the page and click "Uninstall".
If a module has dependencies, you'll need to uninstall the module that requires something else first, then the main module second. For example, Admin Toolbar can not be uninstalled until Admin Toolbar Extras is uninstalled.
Step 2: Remove the module code from the codebase
As you may know, uninstalling a module in Drupal doesn't actually remove the code from the codebase. The code stays in the /modules folder, ready to be installed again. It's always safest to completely removed the code from your codebase.
If you do not have access to the codebase, you will need to ask your IT department or web host to do that for you. If your website is hosted on something like Acquia Cloud or Pantheon, those tools are built-in. If your site is hosted on a popular hosting service such as Hostgator, Hostmonster or Bluehost, you can do that via CPanel. If your site is hosted on a service such as Digital Ocean, you'll need SSH access to delete the files. It's beyond the scope of this tutorial to dive into every service, but suffice it to say, the files should be deleted.
Once you gain access to the codebase, you'll look for the modules folder. Your module will be listed via the machine name. Just delete the entire folder. In the illustration below, to delete the Asset Injector module, you would delete the asset_injector folder.
One Final Thought
While it might be tempting to uninstall Core modules that you're not using, it really won't help. The modules you remove will be reinstalled on the next Drupal update regardless.
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web