Wix CLS (Cumulative Layout Shift) Optimization
Cumulative Layout Shift (CLS) measures visual stability by tracking unexpected layout shifts. Good CLS should be under 0.1. This guide covers Wix-specific strategies to eliminate layout shifts.
Understanding CLS on Wix
What is CLS?
CLS quantifies how much page content shifts unexpectedly during loading. Common causes:
- Images without dimensions loading
- Fonts swapping in late
- Dynamically injected content
- Ads or embeds loading
- Animations and transitions
Wix-Specific CLS Challenges
- Dynamic content loading - Wix loads many elements progressively
- Third-party apps - Pop-ups, chat widgets, and embeds shift content
- Font loading - Custom fonts cause text reflow
- Responsive containers - Elements resize based on content
- Animations - Wix's default scroll effects can cause shifts
Target CLS Scores
| Score | Rating | User Experience |
|---|---|---|
| 0-0.1 | Good ✅ | Stable, no unexpected shifts |
| 0.1-0.25 | Needs Improvement ⚠️ | Noticeable but acceptable |
| 0.25+ | Poor ❌ | Frustrating, error-prone |
Diagnosing CLS Issues
1. Measure Current CLS
PageSpeed Insights:
- Visit PageSpeed Insights
- Enter your Wix URL
- Check "Cumulative Layout Shift" metric
- Important: Test both mobile and desktop
Chrome DevTools:
- Open DevTools (F12)
- Lighthouse tab → Generate report
- Find CLS under "Metrics"
- Click to see shift sources
2. Identify Shift Sources
Layout Shift Regions (in PageSpeed):
- Scroll to "Diagnostics"
- Look for "Avoid large layout shifts"
- Shows screenshots with shifted elements highlighted
Using Chrome DevTools:
- Performance tab
- Click Record (circle)
- Scroll through your page
- Stop recording
- Find Experience row
- Look for red Layout Shift bars
- Click to see which elements shifted
3. Common CLS Culprits on Wix
Most common issues:
- Hero images loading without reserved space
- Wix chat widgets appearing
- Pop-ups and promotional bars
- Third-party embeds (social feeds, reviews)
- Dynamic forms
- Font swapping (FOUT - Flash of Unstyled Text)
Image-Related CLS Fixes
1. Set Image Dimensions
Wix should handle this automatically, but verify:
Check image settings:
- Editor → Click image
- Settings → Layout
- Ensure width/height are set (not "auto")
Best practice:
- Use fixed aspect ratio for images
- Avoid dynamic resizing based on content
2. Reserve Space for Hero Images
Hero section shifts are most impactful:
Solution:
Set minimum height for hero section:
- Editor → Click hero strip
- Settings → Layout
- Set minimum height (e.g., 500px)
Use background images instead of inline images
- Less likely to cause shift
- Wix handles sizing better
3. Optimize Image Loading
Disable lazy loading for above-fold images:
- Media Manager → Select image
- Settings
- Disable Lazy loading for critical images
Why: Lazy-loaded images can shift when they load late.
4. Aspect Ratio Containers
For dynamic images, use aspect ratio boxes:
Velo implementation:
$w.onReady(function () {
const image = $w('#dynamicImage');
// Set aspect ratio container
image.onLoad(() => {
// Image loaded, no shift occurs
});
});
Font-Related CLS Fixes
1. Use System Fonts
Best solution: Use system fonts (no loading = no shift).
System font stack:
- Arial, Helvetica, sans-serif
- Georgia, Times, serif
- Courier, monospace
How to set:
- Editor → Design → Fonts
- Select web-safe fonts
2. Minimize Custom Fonts
If custom fonts are required:
Best practices:
- Limit to 2 font families
- Only include needed weights
- Use
font-display: swap(Wix handles this)
3. Preload Critical Fonts
Reduce font load time to minimize shift:
<!-- Dashboard → Settings → Custom Code → Head -->
<link rel="preload" as="font" type="font/woff2"
href="YOUR_FONT_URL" crossorigin />
Find font URL:
- Inspect text element
- Check Network tab for font requests
- Copy font URL (usually
static.wixstatic.com/...)
4. Font Display Strategy
Wix uses font-display: swap by default, which can cause shifts.
Understanding the trade-off:
swap- Shows fallback font immediately, then swaps (causes CLS)optional- Uses fallback if custom font not ready (better CLS)
Note: Wix doesn't expose font-display settings directly. Consider using system fonts for critical text.
Third-Party App CLS Fixes
1. Chat Widgets
Live chat widgets are major CLS culprits.
Solutions:
Option 1: Delayed loading
// Site Code - Delay chat widget
$w.onReady(function () {
setTimeout(() => {
// Initialize chat widget here
loadChatWidget();
}, 3000); // 3-second delay
});
Option 2: Reserve space
<!-- Custom Code → Head -->
<style>
/* Reserve space for chat button */
body::after {
content: '';
position: fixed;
bottom: 20px;
right: 20px;
width: 60px;
height: 60px;
pointer-events: none;
}
</style>
Option 3: Remove chat widget
- Consider replacing with contact button
- Reduces CLS significantly
2. Pop-ups and Promotional Bars
Best practices:
Delay pop-up appearance:
- Settings → Set trigger to 5+ seconds
- Or scroll-based trigger
Use overlay (not push-down):
- Overlays don't shift content
- Push-down bars cause major CLS
Fixed positioning:
- Ensure pop-ups use
position: fixed - Prevents content reflow
- Ensure pop-ups use
Wix settings:
- Dashboard → Marketing Tools → Pop-ups
- Ensure "Push down content" is disabled
3. Social Media Embeds
Instagram, Facebook, Twitter embeds cause shifts.
Solutions:
Option 1: Static placeholders
Option 2: Reserve space
<!-- Wrapper for embed -->
<div style="min-height: 400px;">
<!-- Embed code here -->
</div>
Option 3: Lazy load embeds
- Load embeds only when scrolled into view
- Use Velo to control loading
$w.onReady(function () {
$w('#embedSection').onViewportEnter(() => {
// Load embed
loadSocialEmbed();
});
});
4. Review Widgets
Review and testimonial widgets often shift.
Solutions:
- Set fixed height container
- Use static testimonials instead of dynamic widget
- Load reviews below the fold
Wix-Specific Techniques
1. Disable Scroll Effects
Wix scroll effects can cause layout shifts.
How to disable:
- Editor → Click section/element
- Settings → Scroll Effects
- Set to None
Repeat for all above-fold sections.
2. Optimize Strips/Sections
Wix strips can shift when loading:
Best practices:
Set fixed height for critical strips
- Editor → Strip settings → Layout
- Set minimum height
Avoid "Fit to screen" for strips with dynamic content
- Can cause shifts as content loads
Use background images instead of inline images in strips
- More stable rendering
3. Fix Repeater Shifts
Wix repeaters loading can cause major shifts.
Solutions:
Option 1: Set container height
$w.onReady(function () {
// Set repeater container min-height before data loads
$w('#repeater').collapsed = false;
$w('#repeater').data = []; // Placeholder
});
Option 2: Skeleton loading
- Show placeholder items while loading
- Prevents shift when real data loads
Option 3: Fixed item count
- Always show same number of items
- Use pagination for more
4. Mobile Menu Shifts
Mobile menu appearing can shift content.
Wix mobile menu best practices:
- Use overlay menu (not push-down)
- Ensure menu is
position: fixed - Test menu opening/closing for shifts
Check settings:
- Editor → Mobile view → Menu
- Settings → Display type: Overlay
Form-Related CLS
1. Wix Forms
Forms expanding/validating can cause shifts.
Solutions:
- Reserve space for error messages:
<style>
.wixForms__errorMsg {
min-height: 20px;
/* Prevents shift when error appears */
}
</style>
Fixed form height:
- Editor → Form settings → Layout
- Set fixed height
Inline validation (preferred):
- Validates without layout shift
- Settings → Validation: Inline
2. Dynamic Form Fields
Fields appearing based on selections:
Best practice:
- Use visibility toggle, not DOM insertion
- Keeps layout stable
$w('#conditionalField').hide();
$w('#triggerDropdown').onChange((event) => {
if (event.target.value === 'option') {
$w('#conditionalField').show(); // Toggle visibility
}
});
Animation & Transition CLS
1. Wix Animations
Animations can trigger layout shifts.
Safe animations (no CLS):
opacitychangestransform(translate, scale, rotate)
Unsafe animations (cause CLS):
width/heightchangesmargin/paddingchangestop/left(withoutposition: absolute)
How to fix:
- Editor → Element → Animations
- Choose animations that don't shift layout:
- Fade in (opacity)
- Slide in (transform)
- Avoid: Grow, expand
2. Hover Effects
CSS hover effects can shift content if not careful.
Safe hover effects:
/* Scale without shifting */
.element:hover {
transform: scale(1.05);
}
/* Change color only */
.element:hover {
background-color: blue;
}
Unsafe hover effects:
/* BAD: Shifts layout */
.element:hover {
padding: 20px; /* Don't change box model on hover */
}
Advanced Fixes (Velo)
1. Preload Content Heights
Calculate and reserve space before content loads:
$w.onReady(async function () {
// Reserve space for dynamic content
const expectedHeight = 400; // Calculated or estimated
$w('#dynamicSection').height = expectedHeight;
// Load content
const content = await fetchContent();
$w('#dynamicSection').html = content;
});
2. Skeleton Screens
Show placeholder content while loading:
$w.onReady(function () {
// Show skeleton
$w('#skeletonLoader').show();
$w('#actualContent').hide();
// Load data
loadData().then(() => {
$w('#skeletonLoader').hide();
$w('#actualContent').show();
});
});
3. Batch DOM Updates
Minimize layout recalculations:
$w.onReady(function () {
// BAD: Multiple reflows
$w('#element1').show();
$w('#element2').show();
$w('#element3').show();
// GOOD: Single reflow
Promise.all([
$w('#element1').show(),
$w('#element2').show(),
$w('#element3').show()
]);
});
Testing & Validation
1. Visual Comparison
Record before/after:
- Take video of page loading (before fixes)
- Implement CLS fixes
- Take video of page loading (after)
- Compare for visible shifts
2. Automated Testing
PageSpeed Insights:
- Test before and after
- Note CLS score improvement
Chrome DevTools:
- Record performance profile
- Check for layout shift events
3. Real User Monitoring
Track actual user CLS:
// Track CLS to GA4
import { getCLS } from 'web-vitals';
getCLS((metric) => {
if (window.gtag) {
gtag('event', 'web_vitals', {
event_category: 'Web Vitals',
event_label: 'CLS',
value: Math.round(metric.value * 1000), // Convert to integer
non_interaction: true
});
}
});
CLS Optimization Checklist
- Set fixed dimensions for all images
- Reserve space for hero section
- Use system fonts (or preload custom fonts)
- Delay/remove chat widgets
- Disable scroll effects on critical sections
- Use overlay pop-ups (not push-down)
- Set fixed heights for strips/sections
- Replace social embeds with static content
- Reserve space for form error messages
- Test mobile menu behavior
- Remove or stabilize third-party widgets
- Test with PageSpeed Insights
- Monitor real user CLS in Search Console
Expected Results
After optimization:
| Improvement | Expected CLS Reduction |
|---|---|
| Remove chat widget | 0.1-0.3 |
| Fix image dimensions | 0.05-0.15 |
| Use system fonts | 0.03-0.10 |
| Stabilize pop-ups | 0.05-0.20 |
| Disable scroll effects | 0.02-0.08 |
| Fix third-party embeds | 0.10-0.25 |
Realistic target:
- Desktop: < 0.05 (achievable)
- Mobile: < 0.1 (challenging but possible)
Common CLS Issues & Solutions
| Issue | Typical CLS | Solution |
|---|---|---|
| Chat widget appears | 0.15-0.30 | Delay load or remove |
| Hero image loads | 0.10-0.20 | Set fixed height |
| Custom fonts swap | 0.05-0.15 | Use system fonts or preload |
| Pop-up appears | 0.10-0.25 | Use overlay, not push-down |
| Social feed loads | 0.15-0.35 | Replace with static content |
| Form errors appear | 0.03-0.10 | Reserve space for messages |
When CLS Can't Be Improved Further
Some Wix elements are beyond your control:
- Platform-injected content - Wix adds elements you can't modify
- Required third-party widgets - Some apps are necessary
- Responsive behavior - Mobile layouts may inherently shift more
In these cases:
- Document limitations for stakeholders
- Focus on fixing controllable issues
- Consider platform migration for CLS-critical sites