Update GTM script loading to lazyOnload#275
Conversation
…oading strategy to lazyOnload
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Moved poster preload link from RootLayout to improve LCP on non-homepage routes. - Added early rendering of frontmatter image in blog posts to enhance LCP. - Replaced video element with LazyVideo component in MatlabOnlinePage for better performance. - Updated MarkdownRenderer to conditionally load images with eager loading for hero images.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 50802dd. Configure here.
| // Next.js Image component handles lazy loading better by default, | ||
| // but for markdown we'll use a standard img tag with better attributes | ||
| // The hero image or first image should usually be eager loaded | ||
| const isFirstImage = src?.includes('free-matlab-alternatives-2026') || false; // Hacky way to detect hero |
There was a problem hiding this comment.
Hardcoded isFirstImage check is dead code on arrival
Low Severity
The isFirstImage check hardcodes 'free-matlab-alternatives-2026' to eagerly load a specific hero image, but the same commit removes that image from the markdown content of matlab-alternatives.md and moves it to a frontmatter-driven Image component in page.tsx. This detection will never match any image actually rendered through MarkdownRenderer, making the entire isFirstImage conditional (and its fetchPriority/loading branching) dead code.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 50802dd. Configure here.
| priority={true} | ||
| /> | ||
| </div> | ||
| )} |
There was a problem hiding this comment.
Hero image duplicates inline image on multiple blog posts
High Severity
The new frontmatter-driven hero image renders for every blog post that has an image field, but the inline markdown image was only removed from matlab-alternatives.md. At least three other posts (from-ad-hoc-checkpoints-to-reliable-large-data-persistence, in-defense-of-matlab-whiteboard-style-code, introducing-runmat-cloud) have the same image in both frontmatter and their markdown body, causing the image to appear twice on those pages.
Reviewed by Cursor Bugbot for commit 50802dd. Configure here.


…
Note
Medium Risk
Tweaks load priority for images, videos, and GTM, which can change perceived performance and analytics firing timing across key pages. Main risk is unintended regressions in above-the-fold rendering or missing/late tracking on production.
Overview
Improves perceived performance by adjusting what loads eagerly vs lazily across the site.
Blog posts now render the frontmatter
imageas an early,priorityNextImagehero (and removes the duplicated in-body markdown image inmatlab-alternatives.md) to boost LCP. Markdown image rendering is updated to setloading/fetchPriority/decodingattributes (with a special-case to eagerly load the first/hero image).Moves the global homepage poster preload out of
RootLayoutto avoid hurting LCP on non-home routes, swaps thematlab-onlinehero from a plain<video autoPlay>toLazyVideoto defer video loading until in-view, and changesGoogleTagManagerscript loading fromafterInteractivetolazyOnload.Reviewed by Cursor Bugbot for commit 50802dd. Bugbot is set up for automated code reviews on this repo. Configure here.