What are the advantages of Large Media vs saving images in src?

I’m creating a react app which will serve some images (~200 kb each). If I want to serve the images dynamically from different pages in the app, is it better to import the images through the react source code? Or is it better to use Large Media?

Are there advantages of using Large Media, such as worldwide CDN which is able to deliver the images faster? Or other considerations I don’t know about?

1 Like

Hey @zhjngli! :wave:t2:

A great question, and a good reminding dig for me too, so thanks!

Here’s a few things.

  • With most Git LFS implementations, you get dynamic out-of-the-box image transformations.
  • Your repository size stays small (just code) - which can be an issue depending on how much content you have (GitHub does have a maximum repo size, btw!)
  • Cloning your repo is significantly faster (remember that the Netlify Build agent clones your repo to the build box when you build)
  • “Media” can be a gray line for images (I keep the images for my website in Git, truth be told) but that’s a very different story when you’re talking about music/audio, videos, etc. – Lots of other content types easily reach the multi-GB range! You can’t keep those in a repo :stuck_out_tongue:

Hope that helps!


Jon

1 Like

I thought one of the main features of Netlify large media was the image transformation? I often see it recommended that you use Git LFS if you aren’t taking advantage of the transformation. Just curious as you mention most come with transformations out of the box, any examples? :slight_smile:

Are there any considerations other than cloning or image transformations?

Also, are the image transformations really fast? If I already know the sizes of each image I might need to load, it seems that it could be better to generate a few different sizes and store it in src

Yeah that can work in some cases, but if your pile of images is already 1GB then you want to additionally generate and store thumbnails, your repo will start failing :stuck_out_tongue:

They are very fast, and I believe they get cached as well so once they’re generated, they’re available as fast as your static images would be anyway. Haven’t read too deep into Netlify’s LFS (though I just lined up a project where I’ll need to use it so I’ll learn quick…) but I would imagine they cache based on a hash of the image file itself, so transformations etc. ought to be the same across deploys if the images don’t change. Just meaning that I don’t think transformations would need to regenerate on each deploy :slight_smile:


Jon

1 Like

Thanks! Yea, that makes sense, I remember vaguely reading elsewhere that hashing could slow down Netlify’s robust caching

1 Like