Skip to content

Images with display: none are still being fetched #1035

Open
@madebyfabian

Description

@madebyfabian

I have some images that are only specifically displayed on mobile/desktop. With the regular <img /> tag, setting them to display: none will not load any images. But with <NuxtImg />, the image also gets fetched, even though it's never displayed. This costs some unnecessary bandwith for mobile users.

Reproduction

https://stackblitz.com/edit/github-p3cr3h?file=nuxt.config.ts,app.vue

Workarounds

  1. Doing a v-if and listening to the screen size in JavaScript. That would not be good for initial loading and SEO.
  2. Adding loading="lazy" which will also not be good since the images are in the first loading viewport (in my case)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions