Skip to content

Commit

Permalink
fix(audits): Don't warn about loading on data URIs (#10275)
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored Mar 1, 2024
1 parent d5277df commit 5e3e74b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-buttons-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes dev toolbar warning about using the proper loading attributes on images using `data:` URIs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const perf: AuditRuleWithSelector[] = [
// Ignore elements that are above the fold, they should be loaded eagerly
if (htmlElement.offsetTop < window.innerHeight) return false;

// Ignore elements using `data:` URI, the `loading` attribute doesn't do anything for these
if (htmlElement.src.startsWith('data:')) return false;

return true;
},
},
Expand All @@ -53,6 +56,9 @@ export const perf: AuditRuleWithSelector[] = [
// Ignore elements that are below the fold, they should be loaded lazily
if (htmlElement.offsetTop > window.innerHeight) return false;

// Ignore elements using `data:` URI, the `loading` attribute doesn't do anything for these
if (htmlElement.src.startsWith('data:')) return false;

return true;
},
},
Expand Down

0 comments on commit 5e3e74b

Please sign in to comment.