GithubHelp home page GithubHelp logo

Bug: Random preloads added for images about react HOT 3 OPEN

muteor avatar muteor commented on April 28, 2024 1
Bug: Random preloads added for images

from react.

Comments (3)

nickluger avatar nickluger commented on April 28, 2024 1

Thanks for the info regarding loading=lazy, that could solve it. 🙏

If this is really a "feature", I have to say, I don't think it should be React's business to put stuff into my <head> automagically…

from react.

nickluger avatar nickluger commented on April 28, 2024

This. Tested with 19.0.0-canary-a73c3450e-20240329.

It would be "kinda" tolerable for the LCP image above fold (featured image or similar), but we have lots of lazy loaded images below fold which contain alternatives like:

<img
  {...imgProps}
/>
<noscript>
  <img
    alt={alt}
    src={noscriptSrc}
  />
</noscript>

For every <img> tag used in noscript, the image is preloaded in <head> which completely defies the purpose of lazy loading.

from react.

muteor avatar muteor commented on April 28, 2024

I think this is actually now expected behaviour, after digging the source a bit I found f359f9b

Though I could not find any docs/release notes that mention this which is a little odd as now you need to explicitly think about the loading strategy of every img tag you use. For me I was able to "fix" this by making sure all our img tags have either loading=lazy or fetchPriority=low when they are not to be preloaded, this gave me more or less only the LCP images preloaded.

@nickluger For your case you could either add loading=lazy or fetchPriority=low to the fallback images, though depending on your target browsers you could get rid of the noscript parts these days as loading=lazy has pretty wide browser support now.

Would be good to have this documented somewhere and also maybe add this to the react linter.

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.