Prompt
How do I embed marketing videos in a landing page without slowing it down?
Latest observation
To embed marketing videos in a landing page without hurting performance, the key is to avoid loading the full video player and file until the user actually interacts.
Here are the best practices:
1. Use a lightweight thumbnail first
Instead of loading the full video embed on page load, show:
- a static thumbnail/poster image
- a play button overlay
Then load the video only when clicked.
2. Lazy-load the video player
If you use YouTube, Vimeo, or another host, don’t embed the iframe immediately.
Use a placeholder div and inject the iframe only after user interaction.
This avoids:
- extra JavaScript
- tracking scripts
- large network requests
- render-blocking behavior
3. Use self-hosted MP4s carefully
If you host the video yourself:
- compress it properly
- use modern formats like WebM and H.264 MP4
- serve adaptive streaming if possible
- add
preload="none"orpreload="metadata"on the<video>tag
Example:
<video controls preload="none" poster="thumbnail.jpg">
<source src="video.webm" type="video/webm">
<source src="video.mp4" type="video/mp4">
</video>
4. Don’t autoplay by default
Autoplaying videos can:
- increase bandwidth usage
- hurt Core Web Vitals
- annoy users
If you must autoplay, use:
- muted
- playsinline
- short loops
- very small files
5. Compress the video aggressively
For landing pages, keep videos short and optimized:
- 15–60 seconds if possible
- remove unnecessary audio
- lower resolution if full HD isn’t needed
- encode with a modern codec
A lightweight video often performs better than a flashy high-res one.
6. Use a CDN
Serve video and thumbnails from a CDN so they load faster globally and don’t strain your origin server.
7. Optimize thumbnails separately
A heavy poster image can be just as bad as a video. Use:
- WebP or AVIF
- correct dimensions
- responsive image sizes
8. Load analytics and embeds after interaction
Third-party video embeds often load tracking scripts.
Delay them until click, or use privacy-friendly embed modes if available.
9. Preconnect only when needed
If you know the video host will be used, you can add:
<link rel="preconnect" href="https://www.youtube.com">
<link rel="preconnect" href="https://i.ytimg.com">
But don’t overdo it—use only for the domains you actually need.
10. Measure impact
Check:
- Largest Contentful Paint (LCP)
- Interaction to Next Paint (INP)
- Total Blocking Time (TBT)
- page weight and requests
Tools:
- Lighthouse
- PageSpeed Insights
- WebPageTest
Best approach in practice
For most landing pages, the fastest pattern is:
- Show a thumbnail + play button
- Load the embed only on click
- Keep the video short and compressed
- Use a CDN
- Avoid autoplay unless absolutely necessary
If you want, I can give you:
- a copy-paste HTML/JS lazy-load video embed
- or a React/Next.js version