Case Study: Speeding Up a Multilingual WordPress Site and Slow AJAX Search
A real case study speeding up a bilingual corporate WordPress site: fixing RTL/LTR layout shifts, cleaning up scripts, and making AJAX live search and TTFB fast.
In this article
When working on complex WordPress projects and multilingual corporate platforms, loading speed and visual stability are among the most critical technical challenges. Clients often come to us with websites that look polished on the surface, yet suffer from sluggish interactions, layout shifts during page load, and slow server responses that hurt both user experience and Google rankings.
In this practical case study, I share the step-by-step methodology I used recently while optimizing a multilingual corporate WordPress platform—and how we resolved the underlying bottlenecks affecting Largest Contentful Paint (LCP), Interaction to Next Paint (INP), and Cumulative Layout Shift (CLS).
Key takeaways
- Diagnose before caching: Installing random caching plugins without inspecting the network waterfall hides symptoms temporarily without fixing root causes.
- Static images across languages hurt LCP & CLS: Missing explicit dimensions or inconsistent asset rendering between LTR and RTL layouts directly degrades visual stability.
- Clean up redundant scripts and console errors: Conditionally dequeuing unused CSS/JS and fixing JavaScript console errors frees up the main thread and improves INP.
- Optimize live AJAX search: Adding input debouncing, request cancellation (
AbortController), and leanWP_Queryparameters prevents database spikes and lowers TTFB.
Step 1: Diagnosing the Real Performance Bottlenecks
Every effective speed optimization starts with measurement rather than guesswork. Instead of stacking caching plugins right away, I audited the site’s core templates using Chrome DevTools and PageSpeed Insights—following the same diagnostic principles covered in our comprehensive WordPress Core Web Vitals guide.
The audit revealed four primary bottlenecks:
- Unoptimized above-the-fold images: Large hero and static section images delaying LCP.
- Render-blocking CSS and JavaScript: Global plugin assets loading on every page even when only needed on a single template.
- Multilingual layout inconsistencies: Static images and typography shifting between the primary and secondary language layouts, driving up CLS.
- Heavy background AJAX calls: Custom live search queries hitting the database on every keystroke and inflating TTFB (Time to First Byte).
Step 2: Fixing Image Rendering and Multilingual Layout Shifts
Images are usually the heaviest resources on any web page. On a bilingual WordPress website (serving both Arabic RTL and English LTR), the problem compounds when static images lack reserved aspect ratios or swap late via client-side scripts.
To eliminate these bottlenecks, I focused on three targeted fixes:
- Explicit image dimensions (
width,height, andaspect-ratio): Ensuring the browser reserves the exact layout box before the image downloads, reducing CLS to near zero. - Prioritizing the LCP element: Adding
fetchpriority="high"andloading="eager"to the primary above-the-fold visual while lazy-loading offscreen media. - Consistent server-side asset delivery: Serving properly sized WebP images with responsive
srcsetattributes directly from PHP templates rather than relying on JavaScript layout adjustments.
Step 3: Cleaning Up Scripts and Browser Console Errors
Even when a website appears to work normally, silent JavaScript exceptions in the browser console and unused third-party scripts block the main thread and delay user interactions (INP).
Our script optimization pass included:
- Conditional asset enqueueing: Auditing
wp_enqueue_scriptandwp_enqueue_stylehooks so sliders, form scripts, and interactive widgets only load on the pages that actually render them. - Non-blocking execution (
deferandasync): Streamlining asset delivery paths so non-critical scripts never block initial HTML parsing. - Eliminating console errors: Tracing and fixing hidden WordPress console errors that were firing on every page view.
Step 4: Optimizing Custom AJAX Search and Database Queries
A major hidden bottleneck in many corporate sites and WooCommerce stores is custom live search functionality. Poorly optimized search boxes trigger an uncached database query on every single keystroke, overloading MySQL and slowing down TTFB across the entire server.
By refactoring the search script and backend handler, we cut server load dramatically:
- Input debouncing (300ms): Waiting until the user pauses typing—and requiring a minimum character count—before firing an AJAX request.
- Aborting stale requests (
AbortController): Automatically cancelling in-flight network requests when the user types a new character. - Streamlining
WP_Query: Limiting search queries to essential fields, settingno_found_rows => truefor dropdown previews, and caching repeated lookups.
Summary: Common WordPress Bottlenecks and Engineering Fixes
| Core Metric | Bottleneck Identified | Engineering Fix Applied | Measurable Outcome |
|---|---|---|---|
| LCP (Loading Speed) | Uncompressed hero images & render-blocking CSS/JS | WebP conversion, fetchpriority="high", and deferred non-critical scripts | Main content renders cleanly under 2.0s |
| CLS (Visual Stability) | Missing image dimensions & late RTL/LTR layout swaps | Explicit width/height attributes and server-rendered language layouts | Near-zero layout shift (CLS < 0.05) |
| INP (Interactivity) | Redundant global scripts & unhandled console errors | Conditional script dequeuing and console error cleanup | Snappy menu, filter, and button response |
| TTFB (Server Response) | Unthrottled AJAX live search queries on every keystroke | 300ms debounce, AbortController, and optimized WP_Query | Lower CPU/MySQL load and faster response |
Frequently asked questions
Why is my WordPress site still slow after installing a caching plugin?
A caching plugin serves static HTML faster, but it cannot fix oversized images, main-thread JavaScript bottlenecks, console errors, or uncached AJAX requests like live search and cart fragments. True Core Web Vitals optimization requires fixing both server delivery and front-end asset execution.
How does a multilingual setup affect WordPress Core Web Vitals?
If a multilingual site swaps fonts, stylesheets, or static images on the client side after the page loads, it triggers layout shifts (high CLS) and delays LCP. Rendering the correct language markup and direction (dir="rtl" or dir="ltr") directly on the server—using a lightweight architecture like SaintLang—prevents these shifts.
How do I prevent live AJAX search from slowing down WordPress?
Add a 300ms debounce to the search input, cancel previous pending requests with AbortController, require at least 2–3 characters before querying, and optimize the backend WP_Query with no_found_rows => true and object caching.
When should I refactor a slow WordPress theme vs. rebuild it?
If the slowdown comes from unoptimized images, a few heavy plugins, or fixable script conflicts, targeted refactoring is fast and effective. If the entire layout relies on deeply nested page-builder DOM trees, moving to a clean custom WordPress theme delivers the best long-term speed.
Conclusion and Lessons Learned
Speeding up WordPress and passing Core Web Vitals is never a one-click trick. It takes a disciplined workflow: audit first, fix image rendering and multilingual layout stability next, clean up console errors and redundant scripts, and optimize server-side queries. Keeping your codebase lean is always the most reliable strategy for sustainable SEO and user experience.
If your WordPress website or online store is struggling with slow load times or Core Web Vitals warnings, learn more about Hossam Hamdy or get in touch for a technical performance audit.