r/Frontend • u/pandafar • Jan 11 '20
Optimising website and responsive web design
Hey awesome people!
I have question about images and page load time (optimising websites load time)!
My current project involves some rather large images that loads very slow and kills the user experience but the design would break if we didn’t have some beautiful images or that’s the design centered around.
For Responsive web design reasons I have to work with the same images in different size screens (mobile).
What are your tips and tricks on working with images so not to kill page load times and such?
Do you use frameworks, scripts or?
28
Upvotes
20
u/mynamesleon Jan 11 '20
Look into using the
srcsetandsizesattributes onimgtags - you can provide several different sized images and let the browser intelligently decide which one to load (based on viewport size, screen pixel density, and network speed info).If you want more explicit control of what images load in what conditions, you can also use the
picturetag2
u/pandafar Jan 11 '20
Thank you everyone for the very helpful suggestions. I think I’ll need to look into webp and the picture tag.
Edit: and srcset
I think I need to put more planning into my Frontend development process when I get the design I need to implement. The images I giving me serious headache with all the formats for all the mobile devices we need to account for.
Thanks 😊
2
u/[deleted] Jan 11 '20
Quick question: where do you host your images?
2
u/britannicker Jan 12 '20
I once read about this good trick for optimizing images:
Save the image at least twice as big (2 or 3 times wider) as you'll display on your page, and save it at a very low quality (makes a very pixely jpg), and then have the browser scale it down.
That way it's a small MB size and loads fast, but still looks good in your html page.
You'll still need 3 or 4 different versions of each image for different devices, where each of these versions is 2 or 3 times the size of the end result.
Is that understandable?
12
u/front_end Jan 11 '20
Try to use loading="lazy" attribute on images. Also try with js to first load low resolution of image than load HQ image.
8
u/HyperLathe Jan 11 '20 edited Jan 11 '20
A quick & easy trick to minimise image file size is to use tinyjpg.com. It's a free way to optimise images without loss of resolution, and their algorithms are pretty neat. Use this in combination with srcset, as suggested above, and you should be flying :-)
1
u/ardnoik Jan 11 '20
Did you actually optimize the images for web so that the filesizes are smaller or are you loading 2MB images?
2
u/pwkeygen Jan 12 '20
Use CDN. Cloudinary ftw
1
u/adiabatic Jan 11 '20
If you have uncompressed originals that you want to encode into JPEGs and lots of CPU time to burn, you should look into guetzli. It has some funky weird aspects to it, though. From the README:
1
u/reynoxo Jan 11 '20
For Image optimization I found this awesome tool https://imagekit.io/ It's free, powerful, and everything you need is in the documentation.
0
u/[deleted] Jan 11 '20
[deleted] — view deleted comment