diff --git a/.changeset/warm-buttons-agree.md b/.changeset/warm-buttons-agree.md new file mode 100644 index 0000000000..9186f02828 --- /dev/null +++ b/.changeset/warm-buttons-agree.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes dev toolbar warning about using the proper loading attributes on images using `data:` URIs diff --git a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/perf.ts b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/perf.ts index 197553a25f..4b67fcbf55 100644 --- a/packages/astro/src/runtime/client/dev-toolbar/apps/audit/perf.ts +++ b/packages/astro/src/runtime/client/dev-toolbar/apps/audit/perf.ts @@ -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; }, }, @@ -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; }, },