Skip to content

feat(common): make the warning for lazy-loaded lcp image an error#51748

Closed
atcastle wants to merge 1 commit intoangular:mainfrom
atcastle:make-lazy-lcp-error
Closed

feat(common): make the warning for lazy-loaded lcp image an error#51748
atcastle wants to merge 1 commit intoangular:mainfrom
atcastle:make-lazy-lcp-error

Conversation

@atcastle
Copy link
Copy Markdown
Contributor

@atcastle atcastle commented Sep 12, 2023

This PR upgrades on the of the NgOptimizedImage warnings to an error. The warning upgraded is the one that fires when you don't use the priority attribute on your LCP image, which will cause it to lazy-load and can hurt LCP performance.

This error is only present when the application is run in dev mode. Because the error is thrown outside of the page rendering process, it is logged in the console as an error, but does not interrupt browsing the application. CC: @kara @AndrewKushnir

@pullapprove pullapprove bot requested a review from AndrewKushnir September 12, 2023 22:50
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Sep 12, 2023
@pkozlowski-opensource pkozlowski-opensource added action: review The PR is still awaiting reviews from at least one requested reviewer area: common Issues related to APIs in the @angular/common package common: image directive labels Sep 13, 2023
@ngbot ngbot bot modified the milestone: Backlog Sep 13, 2023
Copy link
Copy Markdown
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit target: major This PR is targeted for the next major release action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: presubmit The PR is in need of a google3 presubmit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Sep 13, 2023
@angular-robot angular-robot bot added the detected: breaking change PR contains a commit with a breaking change label Sep 15, 2023
@AndrewKushnir AndrewKushnir added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Sep 15, 2023
@AndrewKushnir AndrewKushnir removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Sep 15, 2023
@AndrewKushnir AndrewKushnir added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Sep 15, 2023
@AndrewKushnir
Copy link
Copy Markdown
Contributor

Caretaker note: presubmit was "green" prior to rebase. There were no changes to the TS files during the rebase.

@pkozlowski-opensource
Copy link
Copy Markdown
Member

This PR was merged into the repository by commit fe2fd7e.

@pkozlowski-opensource pkozlowski-opensource added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: global presubmit The PR is in need of a google3 global presubmit and removed merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Sep 18, 2023
pkozlowski-opensource added a commit that referenced this pull request Sep 18, 2023
@AndrewKushnir
Copy link
Copy Markdown
Contributor

AndrewKushnir commented Sep 19, 2023

TGP.

@AndrewKushnir AndrewKushnir modified the milestones: Backlog, v17-candidates Sep 28, 2023
@atcastle atcastle force-pushed the make-lazy-lcp-error branch from 8d997f9 to ff7dd58 Compare October 2, 2023 19:51
@angular-robot angular-robot bot requested a review from AndrewKushnir October 2, 2023 19:51
Copy link
Copy Markdown
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atcastle looks good, thanks! Just left a few comments.

A couple additional notes:

  • we should remove the "BREAKING CHANGE" part from the commit message - we are not changing the behavior in this PR. We'll add the message in a followup PR where we flip the default value.
  • it'd be great to add some tests into packages/core/test/test_bed_spec.ts (see existing tests for similar errorOn config options).
  • we can also add some tests to the packages/common/test/directives/ng_optimized_image_spec.ts file to verify correct behavior (throw vs console.warn depending on a setting)

@atcastle atcastle force-pushed the make-lazy-lcp-error branch from ff7dd58 to 5b2d1d7 Compare October 3, 2023 00:31
@angular-robot angular-robot bot removed the detected: breaking change PR contains a commit with a breaking change label Oct 3, 2023
…y an error

add logic to upgrade lazy-load error to warning, if a test bed option is set
@atcastle atcastle force-pushed the make-lazy-lcp-error branch from 5b2d1d7 to 22e192a Compare October 3, 2023 02:04
@AndrewKushnir
Copy link
Copy Markdown
Contributor

TGP.

@AndrewKushnir
Copy link
Copy Markdown
Contributor

@atcastle FYI the TGP is "green" for this PR.

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note state: blocked and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: global presubmit The PR is in need of a google3 global presubmit action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Oct 4, 2023
@AndrewKushnir
Copy link
Copy Markdown
Contributor

Closing this PR in favor of #52004.

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 4, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
…gular#51748)

upgrade the warning for lazy-loaded lcp images when using NgOptimizedImage to an error

BREAKING CHANGE:

Previously when NgOptimizedImage directive detected that an LCP image is lazy-loaded, a console warning was produced. Now the directive throws an error to make it more discoverable in a console. If you receive this error, refer to this guide for additional information: https://angular.io/guide/image-directive#step-4-mark-images-as-priority

PR Close angular#51748
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: common Issues related to APIs in the @angular/common package common: image directive detected: feature PR contains a feature commit state: blocked target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants