perf(frontend): optimize landing page assets — PNG→WebP, video re-encode + Safari fix#268
perf(frontend): optimize landing page assets — PNG→WebP, video re-encode + Safari fix#268
Conversation
Convert landing page images from PNG to WebP and re-encode videos from VP9/WebM to AV1/MP4 for significantly reduced asset sizes. Images (PNG → WebP): - hero-trusted-bg: 2.4MB → 99KB (96% smaller) - screenshot-tui: 1.9MB → 192KB (90% smaller) - screenshot-leaderboard: 1.4MB → 161KB (88% smaller) - follow-3d-avatar: 1.0MB → 61KB (94% smaller) - hero-bg-starfield: 456KB → 13KB (97% smaller) Videos (VP9/WebM → AV1/MP4): - hero-video-transparent: 2.6MB → 473KB (82% smaller) - trophy-cup-transparent: 2.3MB → 326KB (86% smaller) Total: ~12MB → ~1.3MB (89% reduction)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
1 issue found across 18 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/components/landing/sections/HeroSection.tsx">
<violation number="1" location="packages/frontend/src/components/landing/sections/HeroSection.tsx:42">
P2: Using AV1-only MP4 as the sole hero video source can cause playback failures on browsers with partial/no AV1 support (notably Safari variants). Add multi-source fallback (e.g., AV1 + H.264/VP9) so unsupported clients still render the hero video.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/frontend/src/components/landing/sections/HeroSection.tsx
Outdated
Show resolved
Hide resolved
The VP9/WebM videos use alpha_mode:1 for transparent backgrounds (VP9 encodes alpha as a separate layer, not in pix_fmt). Converting to AV1/MP4 dropped the alpha channel. Reverted videos to original WebM format — image optimizations (PNG→WebP) are kept.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d8107e35e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
packages/frontend/src/components/landing/sections/HeroSection.tsx
Outdated
Show resolved
Hide resolved
Re-encode WebM videos with higher CRF (VP9, same container) to reduce size while keeping alpha_mode:1 transparency metadata intact. - hero-video-transparent.webm: 2.6MB → 452KB (83% smaller) - trophy-cup-transparent.webm: 2.3MB → 313KB (86% smaller)
Use -vcodec libvpx-vp9 on input to force VP9 alpha BlockAdditional decoding, then encode with -pix_fmt yuva420p to preserve transparency. - hero-video-transparent.webm: 2.6MB → 497KB (81% smaller) - trophy-cup-transparent.webm: 2.3MB → 413KB (82% smaller)
|
Reviewed the diff — overall this is a clean, high-impact optimization. A few notes: What's good
Minor observations
One thing to verify
LGTM 👍 |
Safari/iOS doesn't reliably play VP9 WebM. Added H.264 MP4 versions of both landing videos as <source> fallbacks. Browsers try WebM first (Chrome/Firefox), then fall back to MP4 (Safari/iOS). Co-Authored-By: Junho Yeo <i@junho.io>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/components/landing/sections/HeroSection.tsx">
<violation number="1" location="packages/frontend/src/components/landing/sections/HeroSection.tsx:47">
P2: This adds a WebM source that doesn’t exist in the repo, causing a failed request for browsers that prefer WebM. Either add the WebM asset or remove this source entry.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Safari 16.4+ claims WebM support and picks the WebM source first, but renders VP9 videos with a black background. The MP4 fallback never kicks in. Fix: - Switch to MP4-only video sources (H.264 is universal) - Remove WebM video files (size diff is only ~235KB total) - Add mix-blend-mode: screen to both video elements so the black video background becomes transparent against the dark page bg Co-Authored-By: Junho Yeo <i@junho.io>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/components/landing/sections/HeroSection.tsx">
<violation number="1" location="packages/frontend/src/components/landing/sections/HeroSection.tsx:42">
P2: This change forces MP4 for all browsers by removing the WebM `<source>` path, causing a performance regression on browsers that support WebM.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/frontend/src/components/landing/sections/HeroSection.tsx
Outdated
Show resolved
Hide resolved
Restore WebM video files and use <source> tags (WebM first, MP4 fallback). The mix-blend-mode: screen is what actually fixes Safari's black background, not the MP4 switch. This way Chrome/Firefox get the smaller WebM files (509KB + 423KB) while Safari falls back to MP4. Co-Authored-By: Junho Yeo <i@junho.io>
Screen blending makes ALL video content semi-transparent (blends with background). Lighten picks max(fg, bg) per pixel — black bg becomes transparent against dark page, but bright video content stays at full opacity. Co-Authored-By: Junho Yeo <i@junho.io>
The page background is already black, so the video's black background blends naturally. The Safari fix is the MP4 <source> fallback, not the blend mode. Co-Authored-By: Junho Yeo <i@junho.io>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/components/landing/sections/HeroSection.tsx">
<violation number="1">
P1: Same issue: PR claims `mix-blend-mode: screen` remains on TrophyVideo, but the file has no blend mode property after this removal. TrophyVideo styled component lacks the claimed Safari fix CSS property.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
gtm kudos |
Summary
cwebp(quality 80)<source>tags — browsers pick the best format they supportmix-blend-mode: screento video elements so the black video background composites transparently against the dark page (fixes Safari rendering black)HeroSection,QuickstartSection,FollowSection,WorldwideSection)Asset Size Reduction
hero-trusted-bg(CSS bg)screenshot-tuiscreenshot-leaderboardfollow-3d-avatarhero-bg-starfieldhero-video-transparenttrophy-cup-transparentContext
Addresses feedback from @SHJordan regarding landing page load performance — 3MB+ images were crushing loading times.
Conversion details
cwebp -q 80— lossy WebP with excellent quality-to-size ratioffmpegVP9 CRF 40 — smaller files for Chrome/Firefoxffmpeg -c:v libx264 -crf 23 -pix_fmt yuv420p -movflags +faststart— H.264 fallback for Safari/iOShero-trusted-bg): The biggest win — this image bypasses Next.js Image optimization entirely since it's served viabackground-image: url(...)Updates since last revision
<source>fallback: The previous commit dropped WebM entirely (MP4-only) to fix Safari. However, this caused a ~235KB performance regression for Chrome/Firefox users. Sincemix-blend-mode: screenis what actually fixes Safari's black video background (not the MP4 switch), we can safely serve both formats. Videos now use<source>children (WebM first, MP4 fallback) so each browser picks its best codec.mix-blend-mode: screenremains on bothHeroVideoandTrophyVideostyled components. The videos areyuv420p(no alpha channel) with black backgrounds; screen blending makes black pixels transparent against the dark page background regardless of which video format the browser selects.Review & Testing Checklist for Human
mix-blend-mode: screenvisual quality on Chrome — this is the main risk. Screen blending changes how video composites with the starfield/globe behind it. Black areas become transparent, but bright video content will also screen-blend with the background. Check that colors/contrast still look correct and not washed out on both the hero and trophy videos.mix-blend-mode: screenvisual quality on Safari — same check, different rendering engine. User confirmed videos are no longer black, but visual quality of the blend effect should be verified.<source>tag approach works and Chrome selects the WebM source (check Network tab).Suggested test plan:
.webmfiles (not.mp4). Verify hero + trophy videos look visually correct with no color distortion from screen blending.Notes
mix-blend-mode: screen. Older Safari without WebM support falls back to MP4, also rendered via mix-blend-mode. Both paths work.yuv420p(no alpha). They have black backgrounds that we're blending away via CSS.mix-blend-mode: screenis a CSS-level solution that works universally, but the tradeoff is that bright video content may look slightly different when screen-blended against the starfield/globe.