Video embed code generator
Paste any video URL and get a lite, lazy-loaded embed snippet you can drop straight into your CMS or static site. Works with YouTube, Vimeo, raw MP4 files, and HostMyVideo URLs.
Direct answer
Q: How do I embed a video without slowing down my page?
A: Use a lite-embed wrapper that lazy-loads the full player on click. This generator detects the video host (YouTube, Vimeo, HostMyVideo, raw MP4) and outputs an iframe or <video> tag with native lazy loading, async/defer scripts, and explicit width/height to lock in the layout shift score.
// Paste a YouTube, Vimeo, MP4 or HostMyVideo URL above to generate the snippet.Why our embed is 2KB: we defer the full player until the visitor clicks play, while the default YouTube/Vimeo embeds ship ~200KB+ on every page view.
See the comparison- Core Web Vitals. Lite embeds defer the full player JS until press-play, so LCP and TBT stay green even with multiple videos above the fold.
- Layout stability. Setting explicit width and height (and the matching aspect-ratio CSS) means Google sees CLS = 0 instead of a layout jump when the iframe mounts.
- Crawl signal. An iframe with a clear src and a sibling poster image is unambiguous to crawlers and AI agents looking for video content on the page.
Embed code questions
What's a lite embed and why is it 2KB?
A lite embed is a thumbnail-only placeholder that swaps in the real player iframe on first click. Until the user clicks play, the page only ships a small bit of HTML, a poster image, and a tiny click handler — typically around 2KB. The full ~200KB+ player JavaScript is deferred until it's actually needed.
Will lite embeds hurt my analytics?
No. Once the user clicks play and the real iframe mounts, every native event the underlying player exposes (YouTube IFrame API, Vimeo Player API, HostMyVideo embed events) fires normally. You're only deferring the load, not breaking the integration.
Why not just use the YouTube share-embed code?
YouTube's default iframe loads ~700KB+ of player JS on every page view, regardless of whether the visitor watches. That tanks LCP and adds third-party cookies. The lite-embed pattern gives you the same result without paying that tax until the user opts in.
Does this work with Vimeo Pro / private videos?
Yes — paste the regular Vimeo URL (vimeo.com/{id}) and the generator outputs a player.vimeo.com iframe. Privacy and domain restrictions you set inside Vimeo are still enforced; the embed code is just the player wrapper.
Can I customize player colors or controls?
Most platforms let you pass extra params (autoplay, color, muted, controls). This generator focuses on the universal baseline. If you need full control over branding and behavior, HostMyVideo gives you a custom-branded player that ships in the same lite-embed wrapper.
Tired of fighting embed weight?
HostMyVideo ships every video with a 2KB lite embed by default. Custom-branded player, AI captions, analytics — all in. 14-day free trial of Pro.