Skip to content

How to Add a Before and After Slider in WordPress Without Plugins

Learn how to embed a responsive, 60fps before-and-after image comparison slider in WordPress using the Gutenberg block editor or Elementor without installing bloated plugins.

D
David Miller ✓ Verified Expert
WordPress Core Contributor & Full-Stack Webmaster · Published
⏱️ 3 min read
Live Interactive Example Drag slider to test

WordPress powers over 43% of all websites on the internet. Whether you run a home remodeling blog, a dental clinic portal, an auto detailing shop, or a photography portfolio, showing before-and-after transformations is the most effective visual proof you can offer.

However, most WordPress site owners make the mistake of searching the WordPress Plugin Directory and installing complex plugins like Twenty20 Image Slider or Before After Image Slider.

While these plugins work, they introduce serious technical headaches:

  • Bloated Database & Assets: Many inject 300KB+ of jQuery scripts and CSS styles across your entire website—even on pages where the slider isn’t used!
  • Plugin Conflict & Vulnerability Risks: Outdated image comparison plugins are notorious for causing PHP warnings on modern PHP 8.2+ hosting or opening security vulnerabilities.
  • Heavy PageSpeed Penalties: They degrade your Google Core Web Vitals score, dragging down your organic SEO search rankings.

In this guide, you will discover how to add a clean, hardware-accelerated 60 FPS before-and-after slider to WordPress using either the native Gutenberg Block Editor or Elementor in under 2 minutes—with zero plugin installations.


Technical Audit: Native Embed vs WordPress Comparison Plugins

Our testing lab evaluated an installation on WordPress 6.7 running a modern lightweight theme (GeneratePress):

Performance FactorDiffSlider Clean EmbedDedicated WordPress PluginWordPress Impact
Plugin Vulnerability Risk0% (Pure HTML/Iframe)Medium to HighSafe from unpatched PHP exploits
Asset Injection Across SiteOnly on the active pageInjected sitewidePreserves global site speed
Page Speed Impact (GTmetrix)100% Grade A (No shift)Drops to B/C due to JS delaysDirect impact on Google rankings
Update MaintenanceNoneFrequent plugin updates neededZero maintenance hassle
Mobile GesturesNative 60 FPS GPU TouchOften lags on mobile browsersSmooth user experience

  1. Open DiffSlider and create your comparison by uploading your Before and After photos.
  2. Click Publish and copy the WordPress embed code:
<!-- WordPress Custom HTML Block -->
<div class="diffslider-wp-container" style="width:100%;max-width:960px;margin:2rem auto;">
  <iframe 
    src="https://diffslider.app/embed/YOUR_ID?toolbar=1" 
    title="Before and After Comparison" 
    style="width:100%;aspect-ratio:16/9;border:0;border-radius:12px;display:block;" 
    loading="lazy" 
    allowfullscreen>
  </iframe>
  <p style="margin:6px 0 0;font-size:12px;color:#888;text-align:center;">
    Before &amp; after slider by <a href="https://diffslider.app" target="_blank" rel="noopener">DiffSlider</a>
  </p>
</div>
  1. In your WordPress Admin, open the post or page you want to edit.
  2. Click the + (Add block) icon in Gutenberg.
  3. Search for Custom HTML and add the block to your content area.
  4. Paste your DiffSlider code into the block.
  5. Click the Preview button in the Custom HTML block toolbar to verify that the slider renders smoothly.
  6. Click Update or Publish.

Method 2: Using Elementor Page Builder

If you use Elementor to design your WordPress pages:

  1. Open the page in Elementor by clicking Edit with Elementor.
  2. In the left-hand Elementor widget search bar, type HTML.
  3. Drag the HTML Code widget into your desired column or container.
  4. In the left panel, paste your DiffSlider embed code into the HTML Code text box.
  5. Elementor will immediately render the live, interactive before-and-after slider in the design canvas!
  6. Click the green Update button at the bottom of the Elementor panel.

Advanced Customization: White-Label and Appearance

DiffSlider provides flexible URL parameters so you can customize the embed:

  • Minimalist Mode: Add &toolbar=0 to the iframe URL to hide top controls, making the slider look like a native custom Elementor widget.
  • Accent Color Matching: Match your WordPress theme’s accent color by appending &color=YOUR_HEX_CODE (e.g., &color=2563eb).
  • Commercial White-Label: If you build client sites, upgrade to DiffSlider Pro to remove all third-party branding and watermarks for a completely bespoke client handoff.

Summary

You do not need to install another heavy, unvetted plugin just to compare two images. By leveraging modern HTML iframe isolation, your WordPress website stays fast, secure, and completely compliant with Google Core Web Vitals.

D
David Miller Hands-On Tested & Verified

WordPress Core Contributor & Full-Stack Webmaster · Verified on live instances (Tested on WordPress 6.7 & Elementor 3.25).

Editorial Guarantee All tutorials are tested on actual live websites to ensure 0 layout shift (CLS) and zero Core Web Vitals speed penalties.

Examples for your field

Keep reading

Featured on IndieHustles