Largest Contentful Paint (LCP) measures how long it takes for the largest visible element to load. Good LCP is critical for user experience and SEO rankings.
LCP Performance Targets
| Rating | LCP Time | Impact |
|---|---|---|
| Good | 0-2.5s | Positive SEO, good UX |
| Needs Improvement | 2.5-4.0s | Neutral SEO, acceptable UX |
| Poor | >4.0s | Negative SEO, poor UX |
Goal: Keep LCP under 2.5 seconds for optimal performance.
Understanding Ecwid's Architecture
Ecwid is a widget-based platform that loads on top of your host page:
Load Sequence
- Host page loads (HTML, CSS, JS)
- Ecwid widget initializes (JavaScript loads)
- Ecwid content renders (Products, categories display)
LCP Considerations
What Counts as LCP:
- Large product images
- Category banners
- Hero images on host page
- Large text blocks
Ecwid-Specific Challenges:
- Widget loads after host page (delayed rendering)
- Product images load dynamically
- JavaScript-heavy rendering
- Third-party dependencies
Measuring LCP
Use PageSpeed Insights
Go to PageSpeed Insights
Enter your Ecwid store URL
Analyze results:
- Mobile score (more important)
- Desktop score
- LCP value and element
Identify LCP element:
- Click "View Treemap"
- Look for largest element
- Note what's causing delay
Use Chrome DevTools
Open page in Chrome
F12 → Performance tab
Record page load
Look for LCP marker:
- Timing info shows when LCP occurred
- Element details show what loaded
Use Lighthouse
# Install Lighthouse CLI
npm install -g lighthouse
# Run audit
lighthouse https://your-ecwid-store.com --view
Optimization Strategies
1. Optimize Host Page Load
Since Ecwid widget loads after host page, optimize host page first.
Minimize HTML Size
Problem: Large HTML delays Ecwid initialization.
Solution:
<!-- Remove unnecessary elements before Ecwid widget -->
<!-- Minimize inline CSS -->
<!-- Defer non-critical scripts -->
Reduce Blocking Resources
Problem: CSS and JS block Ecwid rendering.
Solution:
<!-- Critical CSS inline -->
<style>
/* Only styles needed for above-the-fold */
body { margin: 0; font-family: Arial; }
.ecwid-container { max-width: 1200px; margin: 0 auto; }
</style>
<!-- Load full CSS asynchronously -->
<link rel="preload" href="/styles.css" as="style"
<noscript><link rel="stylesheet" href="/styles.css"></noscript>
<!-- Defer non-critical JavaScript -->
<script src="/script.js" defer></script>
Enable Compression
Gzip or Brotli compression for HTML, CSS, JS:
For Apache (.htaccess):
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript
</IfModule>
For Nginx:
gzip on;
gzip_types text/html text/css application/javascript;
gzip_min_length 1000;
2. Optimize Product Images
Product images are often the LCP element.
Use Optimized Image Formats
Best: WebP
- 30-40% smaller than JPEG
- Excellent browser support
- Lossy and lossless options
How to convert:
- Use online tools (e.g., Squoosh.app)
- Bulk convert:
cwebp input.jpg -o output.webp - Upload WebP to Ecwid
Compress Images
Before uploading to Ecwid:
- Use TinyPNG or ImageOptim
- Target 70-85% quality for photos
- Keep file size under 200KB for main product images
Ecwid Control Panel:
- Ecwid automatically generates thumbnails
- But upload optimized originals for best results
Set Proper Image Dimensions
In Ecwid Settings:
- Settings → General → Instant Site
- Image sizes:
- Product gallery: 1000x1000px (max)
- Thumbnails: 400x400px
- Large: 1500x1500px
Recommendation: Upload at 2x resolution but compressed (e.g., 2000x2000px at 60% quality).
Implement Lazy Loading
Ecwid implements lazy loading by default, but verify:
// Check if lazy loading is enabled
document.querySelectorAll('img[loading="lazy"]').length
If not enabled, force it:
Ecwid.OnPageLoad.add(function() {
// Add lazy loading to images
document.querySelectorAll('.ecwid img').forEach(function(img) {
if (!img.hasAttribute('loading')) {
img.setAttribute('loading', 'lazy');
}
});
});
Add to Custom JavaScript Code section.
Preload LCP Image
If you know which image is LCP (e.g., hero banner):
<!-- Add to host page <head> -->
<link rel="preload" as="image" href="https://cdn-ecwid.com/your-hero-image.webp">
3. Optimize Ecwid Widget Loading
Defer Ecwid Script
Load Ecwid script asynchronously:
Default (blocking):
<script src="https://app.ecwid.com/script.js?12345678&data_platform=code"></script>
Optimized (deferred):
<script src="https://app.ecwid.com/script.js?12345678&data_platform=code" defer></script>
Note: Test thoroughly as this may affect Ecwid initialization.
Use Instant Site (if applicable)
Ecwid Instant Site has better optimization:
- Server-side rendering for initial HTML
- Optimized asset delivery
- Faster initial paint
Enable: Settings → General → Instant Site → Enable
4. Optimize Fonts
Custom fonts can delay LCP if not optimized.
Preload Critical Fonts
<link rel="preload" href="/fonts/main-font.woff2" as="font" type="font/woff2" crossorigin>
Use Font Display Swap
@font-face {
font-family: 'MyFont';
src: url('/fonts/main-font.woff2') format('woff2');
font-display: swap; /* Show fallback immediately */
}
Limit Font Weights
Only load weights you use:
<!-- Bad: loads all weights -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
<!-- Good: only loads what you need -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
5. Reduce Third-Party Scripts
Third-party scripts can significantly delay LCP.
Audit Current Scripts
Check what's loading:
// In console
performance.getEntriesByType('resource')
.filter(r => r.initiatorType === 'script')
.map(r => r.name)
Defer Non-Critical Scripts
Analytics, tracking, chat widgets:
<!-- Bad: blocks rendering -->
<script src="analytics.js"></script>
<!-- Good: deferred -->
<script src="analytics.js" defer></script>
<!-- Better: load after page interactive -->
<script>
window.addEventListener('load', function() {
var script = document.createElement('script');
script.src = 'analytics.js';
document.head.appendChild(script);
});
</script>
Use Facades for Embeds
For YouTube, social media embeds, etc., use facades (lightweight placeholders):
<!-- Instead of full YouTube embed -->
<div class="youtube-facade" data-video-id="VIDEO_ID">
<img src="https://img.youtube.com/vi/VIDEO_ID/maxresdefault.jpg">
<button class="play-button">Play</button>
</div>
<script>
document.querySelectorAll('.youtube-facade').forEach(function(el) {
el.addEventListener('click', function() {
var iframe = document.createElement('iframe');
iframe.src = 'https://www.youtube.com/embed/' + this.dataset.videoId + '?autoplay=1';
this.replaceWith(iframe);
});
});
</script>
6. Implement CDN
Use Content Delivery Network for faster asset delivery.
Ecwid uses CDN by default for:
- Product images
- Ecwid script and assets
For host page:
- Cloudflare (free tier available)
- KeyCDN
- BunnyCDN
Benefits:
- Faster image delivery globally
- Reduced server load
- Automatic image optimization (some CDNs)
7. Enable HTTP/2 or HTTP/3
Modern protocols enable parallel loading.
Check current protocol:
// In console
performance.getEntries()[0].nextHopProtocol
Enable on server:
Apache: Requires mod_http2
Protocols h2 h2c http/1.1
Nginx:
listen 443 ssl http2;
Cloudflare: Enabled automatically
8. Optimize Server Response Time
Fast server = faster Ecwid initialization.
Measure TTFB (Time to First Byte)
Goal: < 200ms
Check:
curl -w "TTFB: %{time_starttransfer}s\n" -o /dev/null -s https://your-store.com
Improve TTFB
Use faster hosting:
- VPS instead of shared hosting
- Managed WordPress hosting (if using WP)
- Upgraded plan with better resources
Enable caching:
- Server-side caching (Varnish, Redis)
- Application caching (WordPress caching plugin)
- Database query caching
Optimize database:
- Regular optimization
- Index frequently queried tables
- Clean up old data
9. Preconnect to Required Domains
Establish early connections to Ecwid servers:
<head>
<!-- Preconnect to Ecwid domains -->
<link rel="preconnect" href="https://app.ecwid.com">
<link rel="preconnect" href="https://app.ecwid.com" crossorigin>
<!-- Preconnect to Ecwid CDN -->
<link rel="preconnect" href="https://d2j6dbq0eux0bg.cloudfront.net">
<link rel="preconnect" href="https://d2j6dbq0eux0bg.cloudfront.net" crossorigin>
</head>
10. Use Resource Hints
Guide browser preloading:
<!-- Preload Ecwid script -->
<link rel="preload" href="https://app.ecwid.com/script.js?12345678" as="script">
<!-- DNS prefetch for analytics -->
<link rel="dns-prefetch" href="//www.google-analytics.com">
<!-- Preconnect to font provider -->
<link rel="preconnect" href="https://fonts.googleapis.com">
Platform-Specific Optimizations
WordPress + Ecwid
Install optimization plugins:
WP Rocket (premium):
- Page caching
- LazyLoad images
- Minify CSS/JS
- Database optimization
Autoptimize (free):
- Minify HTML/CSS/JS
- Defer JavaScript
EWWW Image Optimizer (freemium):
- Automatic image compression
- WebP conversion
Configure exclusions:
- Exclude Ecwid scripts from minification
- Exclude Ecwid pages from aggressive caching
Wix + Ecwid
Wix optimizations:
- Use Wix's built-in image optimizer
- Minimize custom code in header
- Remove unused Wix apps
Limitations:
- Less control over hosting
- Cannot modify server configuration
- Wix loads its own assets
Best practice: Keep Wix page minimal around Ecwid widget.
Squarespace + Ecwid
Optimizations:
- Use Squarespace's built-in image optimization
- Minimize custom CSS
- Use Squarespace's lazy loading
Custom HTML Site + Ecwid
Full control allows all optimizations:
- Choose fast hosting
- Implement all CDN and caching
- Minimize host page weight
- Optimal Ecwid integration
Testing After Optimizations
Re-test with PageSpeed Insights
- Clear cache
- Test in incognito
- Run PageSpeed Insights
- Check LCP improvement
Real User Monitoring
Track actual user LCP:
// Web Vitals library
import {getLCP} from 'web-vitals';
getLCP(function(metric) {
console.log('LCP:', metric.value);
// Send to analytics
gtag('event', 'web_vitals', {
event_category: 'Web Vitals',
event_label: 'LCP',
value: Math.round(metric.value),
non_interaction: true
});
});
Add web-vitals library:
<script type="module">
import {getLCP} from 'https://unpkg.com/web-vitals@3/dist/web-vitals.js?module';
getLCP(console.log);
</script>
Common Issues
LCP Still Poor After Optimization
Possible causes:
- Host page too heavy - Optimize host page first
- Slow hosting - Upgrade or migrate
- Large unoptimized images - Re-compress images
- Too many third-party scripts - Remove or defer
LCP Worse on Mobile
Mobile-specific issues:
- Slower connections
- Less processing power
- Different viewport sizes
Solutions:
- Prioritize mobile optimization
- Use responsive images
- Reduce JavaScript on mobile
Ecwid Widget Causes LCP
If Ecwid content is the LCP element:
- Preload critical Ecwid resources
- Optimize product images heavily
- Consider placeholder content while loading
Monitoring & Maintenance
Regular Audits
Monthly:
- Run PageSpeed Insights
- Check Core Web Vitals in Search Console
- Review image sizes
- Audit third-party scripts
Quarterly:
- Review hosting performance
- Update optimization plugins
- Re-compress older images
- Check for new optimization techniques
Track in GA4
Monitor LCP trends:
- Create Custom Dimension for LCP value
- Track over time to catch regressions
- Segment by device to prioritize
Next Steps
- Optimize CLS - Fix Cumulative Layout Shift
- Events Not Firing - Debug tracking issues
For general performance concepts, see Core Web Vitals Guide.