

Note: Modern image components that build on, like Next.js (for React) and Nuxt image (for Vue) try to bake in as many of these concepts as possible by default. While not render-blocking, they can indirectly impact render performance. Avoid images causing network contention with other critical resources like CSS and JS.


Lazy-load offscreen images (reduce network contention for key resources).Avoid wasting pixels (compress, don’t serve overly high DPR images).Use srcset + efficient modern image formats.Given how central it is to image optimization on the web, let’s catch up on what it can do and how it can help improve user-experience and the Core Web Vitals.įirst, some tips to get us started optimizing our metrics: The humble element has gained some superpowers since it was created. We like images over on the Stack Overflow blog too. Images are so prominent that they are part of the most important content in over ~70% of pages on both mobile and desktop according to the largest contentful paint metric. This isn’t a huge surprise as we humans are quite visual and the tag has been around for almost 30 years. For example, width: 50% causes the image width to be 50% of the containing element (not 50% of the viewport or 50% of actual pixel size).īecause CSS allows content to overflow its container, you may need to use max- width: 100% to prevent images and other content from overflowing.Images are one of the most pervasive parts of the web. Remember to use relative units when specifying widths for images to prevent them from accidentally overflowing the viewport. If your page only has one or two images and these are not used elsewhere on your site, consider using inline images to reduce file requests.

#Fluid image technique in css free#
This is a free course offered through Udacity By the end of the course, you will be developing with images that adapt and respond to different viewport sizes and usage scenarios.
#Fluid image technique in css how to#
In this course you will learn how to work with images on the modern web, so that your images look great and load quickly on any device.Īlong the way, you will pick up a range of skills and techniques to smoothly integrate responsive images into your development workflow. Responsive Images #ĭid you know that images account for more than 60% of the bytes on average needed to load a web page? In this case, changing the image is usually referred to as art direction. Other times the image may need to be changed more drastically: changing the proportions, cropping, and even replacing the entire image. An image that is 50% width may work just fine when the browser is 800px wide, but uses too much real estate on a narrow phone, and requires the same bandwidth overhead when scaled down to fit a smaller screen. For example, on high resolution (2x) displays, high resolution graphics ensure sharpness. Responsive web design means that not only can our layouts change based on device characteristics, but content can change as well. With responsive web design not only can our layouts change based on device characteristics, but images as well. But they also often account for most of the downloaded bytes. Place text in markup instead of embedded in imagesĪ picture is worth 1000 words, and images play an integral part of every page.Use media queries to provide high res images or art direction.Use image-set to provide high res images.Use media queries for conditional image loading or art direction.Art direction in responsive images with picture.Enhance imgs with srcset for high DPI devices.
