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.
Or read how we handle it in Magento 2 Speed Optimization.
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.