Magento's built-in Compare Products feature can add unnecessary clutter and slow down page loads. This guide shows you how to fully remove it using layout XML overrides, CSS rules, and a quick CLI deploy -- keeping your storefront clean and fast.
Why Disable the Compare Feature?
Magento ships with a Compare Products feature that lets shoppers place items side by side. While useful in some contexts, it often adds visual clutter, injects extra frontend scripts, and slows page rendering -- especially on niche or single-product stores where comparison makes little sense.
Removing it delivers three wins:
- Cleaner UI: No extra buttons or links on product and category pages.
- Better UX: Shoppers stay focused on purchasing instead of comparing.
- Faster loads: Unused JavaScript and blocks are no longer rendered.
Step-by-Step Removal
Step 1: Remove Default Compare Blocks via Layout XML
Magento renders compare functionality through layout XML blocks. Override them in your child theme by creating or editing:
app/design/frontend/<Your_Theme>/Magento_Catalog/layout/default.xml
Add the following content:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
<referenceBlock name="category.product.addto.compare" remove="true"/>
<referenceBlock name="catalog.product.link.compare" remove="true"/>
<referenceBlock name="catalogsearch.product.addto.compare" remove="true"/>
<referenceBlock name="view.addto.compare" remove="true"/>
<referenceBlock name="related.product.addto.compare" remove="true"/>
<referenceBlock name="upsell.product.addto.compare" remove="true"/>
<referenceBlock name="product.info.addto.compare" remove="true"/>
<referenceBlock name="product.compare.link" remove="true"/>
</body>
</page>
Step 2: Hide Remaining Buttons via CSS / Less
Some themes may still render compare buttons through JavaScript or templates. Catch any stragglers with CSS:
app/design/frontend/<Your_Theme>/web/css/source/_extend.less
.action.tocompare,
.compare,
a[href*="product_compare"],
li[class*="compare"] {
display: none !important;
}
Step 3: Deploy Your Changes
Run the following from the Magento root directory:
bin/magento setup:upgrade
bin/magento setup:static-content:deploy -f
bin/magento cache:clean
Verifying the Removal
- Browse category pages -- compare links should be gone.
- Open a product detail page -- the compare button should no longer appear.
- Check search results -- compare options should be absent.
Tip: Test in a private/incognito window or clear the browser cache to see the updates immediately.
Going Further
Removing Compare Products is a quick win for stores that do not need it, especially niche or single-product shops. This approach works on Magento 2.4.7 and above with most themes. If you need more advanced storefront optimizations, we at Private DevOps are happy to help.
Frequently asked questions
How do I completely disable Compare Products in Magento 2?
Compare Products is removed in two layers inside the child theme, then redeployed. First, a layout override at app/design/frontend/<Your_Theme>/Magento_Catalog/layout/default.xml removes each compare block with a referenceBlock element set to remove="true". Second, CSS in web/css/source/_extend.less hides any compare buttons a theme still renders through JavaScript or templates. After that, run setup:upgrade, deploy static content and clean the cache.
Which layout blocks render Compare Products in Magento 2?
The nine compare blocks are catalog.compare.sidebar, category.product.addto.compare, catalog.product.link.compare, catalogsearch.product.addto.compare, view.addto.compare, related.product.addto.compare, upsell.product.addto.compare, product.info.addto.compare and product.compare.link. Each one gets a referenceBlock element with remove="true" in Magento_Catalog/layout/default.xml. Removing all of them takes the compare options off category pages, product pages and search results.
Why do compare buttons still show after removing the Magento 2 layout blocks?
Some themes render compare buttons through JavaScript or templates, which the layout override can miss. Catch those stragglers with CSS in app/design/frontend/<Your_Theme>/web/css/source/_extend.less that sets display:none !important on .action.tocompare, .compare, a[href*="product_compare"] and li[class*="compare"]. Redeploy static content afterwards so the new styles reach the storefront.
When should a Magento 2 store disable Compare Products?
Disabling Compare Products makes most sense on niche or single-product stores, where placing items side by side adds little. Removing the feature cleans up product and category pages by dropping the extra buttons and links, and keeps shoppers focused on buying. On stores where shoppers genuinely weigh items against each other, the feature can still be useful.
Does removing Compare Products make Magento 2 faster?
Yes. Compare Products injects extra frontend scripts and slows page rendering. Once the compare blocks are removed through layout XML, the unused JavaScript and blocks are no longer rendered, so each page has less to load.
How do I check that Compare Products is gone from a Magento 2 storefront?
Browse a category page, open a product detail page and run a search, and confirm that no compare link, button or option appears on any of them. Use a private or incognito window, or clear the browser cache first, so the browser shows the updated pages straight away.
Which Magento versions support removing Compare Products with layout XML?
The layout XML and CSS method works on Magento 2.4.7 and above with most themes. Both changes live in the theme folder under app/design/frontend/<Your_Theme>, as a layout override in Magento_Catalog/layout/default.xml and a Less file in web/css/source/_extend.less.
Which commands apply the Compare Products removal in Magento 2?
From the Magento root directory, run bin/magento setup:upgrade, bin/magento setup:static-content:deploy -f and bin/magento cache:clean. Run them once both the default.xml layout override and the _extend.less CSS are in place in the child theme, then test in a private window.
Read how we handle it in DevOps for e-commerce.
Related Articles
How to Disable OpenSearch Security in Magento 2 While Keeping It Private on Ubuntu
OpenSearch ships with SSL and authentication enabled by default, which can complicate Magento 2 integration in development or internal environments. This guide explains how to safely turn off OpenSearch security while restricting access to localhost using Ubuntu's firewall.
MagentoThe Magento 2 Speed Levers That Actually Move LCP
Magento 2 LCP is moved by a small list of high-leverage changes and dragged down by a long tail of myths. The prioritized list of what to fix in order, and the levers that look productive but do not move the LCP needle.
MagentoFixing Magento 2 Custom Options Pagination Limitation -- Instantly Sort All Options with PrivateDevops_CustomOptionsFix
Magento 2's admin paginates custom option values, making it impossible to drag-and-drop sort across pages. PrivateDevops_CustomOptionsFix is a lightweight, upgrade-safe module that loads all option values on a single page so you can reorder them instantly.