And while 0.22% may not sound like a lot, compared to last year, it represents quite a bit of progress. Slowly, the old formats are making way for the new ones, as they should. The new formats outperform the old ones by a significant margin. You will get a sense of that shortly.
This chart shows bits per pixel by format. As you can see, a WWF is more compressed than a WP or JPG. A WWF is a very young format, whose encoders have been quickly iterating. Answering the questions, what format should images be kept in, increased the use of modern formats such as WWF and WP, and of course JPG, where without it, reduced the use of formats like JF and PNG.
The third question is, how do I handle image transformations, and where do I keep various versions of the same image? There are a lot of tools for image optimizations and transformations. Here are some of them. This is an example of an image tag with src and sizes attributes, the familiar way to specify the location of your image. Browsers that do not support src set and sizes will fall back to src. With sizes, you specify the size of the image, and in which situation it must be displayed. This is done by a combination of a media query and the width of an image. With src set, you specify a list of images and different sizes. Another perfectly legit goal with responsive images is not just to show different sizes of the same image, but to show different images. The picture tag has the same logic, but it has a source tag.
The fourth question is how many image sizes to provide to web browsers? This is an interesting question and it all depends on your design. For example, so many images are given on the monger site. A lot, isn't it? The last question is how to upload everything into my existing app? Option 1 is to prepare various versions of the same image in advance and keep them on your server. It's a good option if you don't have thousands of images and the design doesn't change very often. Option 2 is the same, but you can keep images on your regular CDN. Option 3 is to use a proxy server for optimization and transformation of your images. If you're comfortable with Nginx and Docker, for example, you can set up a proxy server on a remote server right away. There are a lot of different open-source projects for this purpose. For example, Fumba, ImageProxy, PicFit and others. You can also write your image optimizer, for example, I've wrote on Nginx, you can view it on GitHub. The advantage is that you can create your URL structure and use only the operation you need. And of course, if Option 3 is not your cup of tea, you can use ImageCDN. For example, Codinary, Amazon, Netlify, nginx, ng-optim, Filestack, Cloudflare and many others.
I hope you have a great time at the JS Nation conference. Thanks for your time.
Comments