fix: lazy load images by default and add priority prop#16
Open
maiieul wants to merge 2 commits into
Open
Conversation
The README documented loading as defaulting to lazy but the component never set it, so every image loaded eagerly. Images now render loading="lazy" by default; the new priority prop renders loading="eager" + fetchpriority="high" for above-the-fold/LCP images. Explicit loading/fetchpriority props take precedence. BREAKING CHANGE: images lazy-load by default; add priority to above-the-fold/LCP images.
🦋 Changeset detectedLatest commit: f9074f7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Updates the qwik-image component to default to lazy-loading (matching the README and common image-component defaults) and introduces a priority prop for above-the-fold/LCP images, along with release tooling to ship this as a major version.
Changes:
- Default
<Image>rendering now includesloading="lazy";priorityrendersloading="eager"+fetchpriority="high"while preserving explicitloading/fetchpriority. - Adds test coverage for default lazy behavior,
prioritybehavior, and explicit override precedence. - Introduces Changesets configuration + pnpm workspace setup to support major-version publishing.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents new priority prop behavior and guidance for LCP images. |
| packages/qwik-image/src/lib/image.tsx | Implements default loading="lazy" and priority prop mapping to eager/high. |
| apps/qwik-demo-app/src/components/image.spec.tsx | Adds tests covering default loading, priority, and explicit overrides. |
| apps/qwik-demo-app/src/routes/index.tsx | Uses priority in the demo route for the main image. |
| apps/qwik-demo-app/vite.config.ts | Adds a Vitest-only alias to avoid a node-environment crash. |
| package.json | Adds @changesets/cli dev dependency. |
| pnpm-workspace.yaml | Adds pnpm workspace definition. |
| pnpm-lock.yaml | Lockfile updates for workspace + Changesets. |
| .changeset/config.json | Adds Changesets configuration. |
| .changeset/lazy-loading-default.md | Declares a major release for the default lazy-loading change + priority. |
| .changeset/README.md | Adds Changesets folder README. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+2
| packages: | ||
| - 'packages/*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is it?
Description
The README documents
loadingas defaulting tolazy, but the component never set it — so every image loaded eagerly, including below-the-fold ones, which hurts LCP. Images now renderloading="lazy"by default (matching next/image, NgOptimizedImage, Astro, Gatsby and Unpic), and the newpriorityprop rendersloading="eager"+fetchpriority="high"for above-the-fold/LCP images. Explicitloading/fetchpriorityprops still take precedence.Since this changes the rendered HTML for every consumer it should ship as a major. Migration is one line: add
priorityto your hero/LCP images.