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.
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 Factor | DiffSlider Clean Embed | Dedicated WordPress Plugin | WordPress Impact |
|---|---|---|---|
| Plugin Vulnerability Risk | 0% (Pure HTML/Iframe) | Medium to High | Safe from unpatched PHP exploits |
| Asset Injection Across Site | Only on the active page | Injected sitewide | Preserves global site speed |
| Page Speed Impact (GTmetrix) | 100% Grade A (No shift) | Drops to B/C due to JS delays | Direct impact on Google rankings |
| Update Maintenance | None | Frequent plugin updates needed | Zero maintenance hassle |
| Mobile Gestures | Native 60 FPS GPU Touch | Often lags on mobile browsers | Smooth user experience |
Method 1: Using the Gutenberg Block Editor (Recommended)
- Open DiffSlider and create your comparison by uploading your Before and After photos.
- 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 & after slider by <a href="https://diffslider.app" target="_blank" rel="noopener">DiffSlider</a>
</p>
</div>
- In your WordPress Admin, open the post or page you want to edit.
- Click the + (Add block) icon in Gutenberg.
- Search for Custom HTML and add the block to your content area.
- Paste your DiffSlider code into the block.
- Click the Preview button in the Custom HTML block toolbar to verify that the slider renders smoothly.
- Click Update or Publish.
Method 2: Using Elementor Page Builder
If you use Elementor to design your WordPress pages:
- Open the page in Elementor by clicking Edit with Elementor.
- In the left-hand Elementor widget search bar, type HTML.
- Drag the HTML Code widget into your desired column or container.
- In the left panel, paste your DiffSlider embed code into the HTML Code text box.
- Elementor will immediately render the live, interactive before-and-after slider in the design canvas!
- 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=0to 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.
WordPress Core Contributor & Full-Stack Webmaster · Verified on live instances (Tested on WordPress 6.7 & Elementor 3.25).