Una’s presentation centered around raster graphics and how they can be better optimized. Though she doesn’t go into it in detail, the implications of poorly-optimized raster images are costly: they tend to be large files, costing our users money in data fees (if on a price-per-MB connection) and time (if on a slow connection) as well as storage and other less-concerning issues.
For the application-heavy work that I tend to do in my day job (my wheelhouse is enterprise web app information architecture) I’m better off with SVG vector images for most uses than raster — iconography is better suited to vector for a number of reasons.
But ooh boy do I have some work to do for my personal WordPress sites.
An Event Apart Seattle 2017 The Joy of Optimizing by Una Kravets (pdf)
The joy of optimizing with @una #aeasea pic.twitter.com/LmRQHW2fbb
— Anne Gibson (@perpendicularme) April 4, 2017
This talk is about images, the medium, solutions, and examples #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
The technology of cameras really changed over time. Way cheaper to take photos, keep data, and share it #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Selfie as assigned by @una #aeasea pic.twitter.com/EsqIWOWcAU
— Anne Gibson (@perpendicularme) April 4, 2017
Cameras we have in the iPhone 7 have 12megapixels of data #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
One image on your iPhone is 2x as much as we want to send into the pipes at any given time #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Petabytes of data – loader spinners! #aeasea (@una can I have that cat gif?)
— Anne Gibson (@perpendicularme) April 4, 2017
(It was an amazing cat gif. Very annoyed cat.)
There are more people on mobile devices than desktop #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Average time for load sites is 19 seconds over 3G #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Mobile sites that loaded within 5 seconds vs 19 observed to have 70% longer average sessions #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
53% of people leave after 3 second #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Nigeria has more internet users than the UK. India is the 2nd largest market #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
https://twitter.com/scott_gruber/status/849390519323172866
Only 34.8% is online, and they’re still the 2nd largest market. What if someone doesn’t browse the web the way I do? #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
India’s average connection speed is 2.5mbps #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
(In contrast, my home Comcast connection is 255 Mbps.)
Access to information should be a basic human right. Poor performance inhibits that right #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
“Performance is your user experience. Performance is a core part of your product.” – @Una #aeasea
— Josh “Yoshi” Vickerson (@joshvickerson) April 4, 2017
A slow load time with 2 factor authentication with timeouts = no github, no logins to critical sites #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
66% of the web is images, by size of the files. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
The average single jpg is 2.3x bigger than the average javascript file. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
(Una pointed out immediately that this doesn’t grant you permission to remove one image from your site and then load a huge javascript file in exchange.)
Right on @Una a reminder about irresponsible imaging #aeasea pic.twitter.com/FzbhWwvQdM
— A Brave New (@abravenew) April 4, 2017
Just emoji alone. Macs vs android vs windows use different formats. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Different images have pros and cons #aeasea pic.twitter.com/3pubIE4AIH
— Anne Gibson (@perpendicularme) April 4, 2017
Gif:
256 colors (8-bit)
No transparency
Dithering (noise to reduce distortion)#AEASEA— Anne Gibson (@perpendicularme) April 4, 2017
Pattern dithering is slightly smaller, and looks a little cross-stitchy #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Thanks to @Una for calling out this Dithr photo during her talk on image optimization at @AnEventApart Seattle! #aeasea #dithr https://t.co/qBOAqCtNsF
— Dithr (@DithrApp) April 4, 2017
PNG
256 colors (8-bit)
True color (24-bit)
Alpha transparency
Lossless format
Uses delta compression#AEASEA— Anne Gibson (@perpendicularme) April 4, 2017
PNGs don’t compress well. JPGs compress really well, but it’s a lossy format, so you lose details with each save #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Even if you save at “Max quality” every time you save a lossy format, the image degrades a little with each save.
How JPGs work #aeasea pic.twitter.com/idnrrtd3la
— Anne Gibson (@perpendicularme) April 4, 2017
Google just released Guetzli Compression – high-quality jpg images compressed 35% smaller than current methods #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Trade-off is it takes a lot longer to save down and works better on bigger images #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Guetzli is a little sharper and not that much smaller #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
While Google says that their compression algorithm is 35% smaller, multiple speakers stated that this was under best possible circumstances and the new algorithm wasn’t necessarily going to win you back 35% of your space just by using it. The link in the next tweet was referenced multiple times as well.
@etportis, @Una just gave you a shootout at #aeasea for your closer look at Guetzli https://t.co/TEwPAjACjE
— ashleigh 👩🏼💻 (@ashleigh8) April 4, 2017
80% quality is probably a good medium level #AEASEA pic.twitter.com/MjKvmUDb0V
— Anne Gibson (@perpendicularme) April 4, 2017
Turns out that histogram thing in Photoshop can be used to show you what’s degrading in your image at different save levels! I had no idea!
According to https://t.co/CC1sI3MkAi we have a lot of formats of jpg (7 versions). Only Safari supports JPG 2000, JPG XR is IE #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
WebP is a promising format. Lossy or lossless. Very comparable of jpg, but much smaller. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
WebP uses predictive coding by looking at the neighbors and then storing differences #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Responsible imaging optimizes artwork to make content accessible for slower connections, networks and devices. #aeasea pic.twitter.com/2WDNYtibcv
— christopher hincks (@chincks) April 4, 2017
WebP is chrome… and that’s about it. #AEASEA Safari and Firefox are experimenting with it
— Anne Gibson (@perpendicularme) April 4, 2017
Can use a lot of techniques to convert to WebP, including a command line version #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
It’s a bit weird to require javascript for users to see your images so a polyfill may not be a great idea #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
The Picture element lets you send different sources to the users so you have fallback #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Webp: A New Image Format By Google https://t.co/lH6sWvsikZ @Una #aeasea
— zeldman (@zeldman) April 4, 2017
WebM is a movie format similar to WebP. Savings are even more dramatic than with stills #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Picture and Video tags allowing multiple sources provide progressive enhancement to your users #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Experimental formats: BPG (Better Portable Graphics). Was designed to replace jpg. Gets a bit smoother, plasticky #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Don’t appear to be plans to be support BPG outside of encoding and a polyfill #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
…which means that while it’s good to see that there are folks trying to make image formats better all the time and GIF/JPG are not our only options until the end of time, BPG is probably a dead-end in the evolution of images.
Flif – free lossless image format – makes a lot of promises #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
You could encode different variations of the source file and then make adjustments within the same image #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Solutions and pro tips:
1. Automation! Image Magick works with many different workflows #AEASEA— Anne Gibson (@perpendicularme) April 4, 2017
Semi-automation: Image Alpha will let you see the changes you’re making to decide in the app #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
ImageOptim will change a whole folder at a time #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
“ImageOptim Always and Often. IOAO” – @Una #aeasea
Couldn’t agree more! Every. Single. Image.
— Josh “Yoshi” Vickerson (@joshvickerson) April 4, 2017
Just running 6 images through ImageOptim saved users 9MB #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Also: there’s an issue open for adding Guetzli compression to @image_optim cc: @Una #aeasea https://t.co/MkSK4pf8gb
— Josh “Yoshi” Vickerson (@joshvickerson) April 4, 2017
SVGOMG lets you optimize SVGs online #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Manual optimization: if you do hero images / splash screen images, save to 30px, then blur up to take space, then pop in on load #aeasea
— Anne Gibson (@perpendicularme) April 4, 2017
Facebook headers are <200 bytes that they can render a blurry small image until the image loads in #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
This is called the “blur up” technique and you can find lots of ways to do it online #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
♛ The “Blur Up” Technique for Loading Background Images @Una #aeasea https://t.co/gBz3L2FMDc
— zeldman (@zeldman) April 4, 2017
Embrace image blur. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Black and white photos are smaller than full color, and blend modes can spice them up #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
The next section of the talk was about different blend modes that can be applied to an image. Sarah Paramenter pointed out that Spotify was using many of these techniques in their image branding during her talk.
I did a lousy job of capturing the details of how blend modes work, so you may want to go read Blending Modes in CSS: Color Theory and Practical Application by Jonathan Cutrell if the following tweets don’t make any sense.
CSS Blend Modes:
Multiply takes luminosity with the background and the image #AEASEA— Anne Gibson (@perpendicularme) April 4, 2017
Screen: does opposite of multiplying lightness values. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Darken: looks at rgb values of two layers, looks at darker colors. Lighten: opposite #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Difference, Exclusion, color burn, color dodge, soft light combines screen and multiply, hard light, overlay #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
(I can’t keep up with all these colors so look them up online they’re awesome) #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
You can combine gradients and mix-blend-modes to do interesting things #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Black and white photo with gradients and blend modes #aeasea pic.twitter.com/ISPY2idPhy
— Anne Gibson (@perpendicularme) April 4, 2017
Put the image on top of the color so that if the blend mode doesn’t work the image still displays black and white #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Support for mix blend mode is still in progress, as is background blend mode #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Blending will cause a repaint #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Still faster to send a black and white image with a pink layer than it is to put the pink layer on photoshop #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
That is, it’s faster for the user to download an optimized black and white image that you use CSS to add a pink layer to than it is for the user to download the exact same optimized color image.
Shout out by @una to @brucel who you should follow for his knowledge and horrible puns #aeasea pic.twitter.com/7hVJ5WbY11
— Anne Gibson (@perpendicularme) April 4, 2017
For example, this gem:
Celebrity Fact number 67: If Kenny Loggins is inactive for 10 minutes, he becomes Kenny Loggedout
— Bruce Lawson (@brucel) April 4, 2017
Anyway, moving on….
GIFs. Send as few frames as possible, adjust the length of frames instead, format the frames #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
GIFs are soooo big in file size. Gifv – Imgur changing GIFs into video files because the videos are actually smaller #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Why is video so much better than a gif? GIFs store every frame, but videos only store the differences between frames #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
To improve image performance:
Where’s the image the biggest? If we’re sending 1560px wide and only showing 780px wide, scale down #AEASEA— Anne Gibson (@perpendicularme) April 4, 2017
“Save Retina images at 2x the size” is the advice we give. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
.@una is challenging that advice – make transformations and test them and see what savings you can get #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
195% improvement in image sizes just by looking for the largest natural size that shows and sizing down to it #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
You literally cost your users money in data fees when you’re sending too-big images. #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Use srcset to check for pixel density if you really need to have the high res image #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
2. Convert JPG to WebP and a polyfill, can save much size #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Use picture element or media queries to send the right size image for the right device #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
If you’re not concerned about performance around the world, you still need to consider mobile performance #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
American users are more likely to shop on mobile devices and we’re impatient #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Step 4: profit. Literally. 1s slowdown cost Amazon $1.6 billion in sales each year #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Image optimization tips:
Don’t send an imag larger than it needs to be #AEASEA— Anne Gibson (@perpendicularme) April 4, 2017
Be aware of emerging image formats, pros and cos #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
(that’s “cons”)
The picture element is your friend! #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Compress your images to low qualities, especially small #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Always run images through an optimizer #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Small improvements are still improvements #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
Educate the entire team #AEASEA
— Anne Gibson (@perpendicularme) April 4, 2017
.@Una dropping the image perf knowledge and practical reasons why you should care #perfmatters #aeasea pic.twitter.com/B2WzNpndFA
— Greg Whitworth (@gregwhitworth) April 4, 2017
Build a better web, faster, more accessible, small incremental changes with a big impact overall #aeasea
— Anne Gibson (@perpendicularme) April 4, 2017
Hard proof that optimizing images is critical: when Una asked us all to take selfies, our phones immediately backed up the full-size images across the network to our various cloud services and DDOS’d the conference wifi.
I made everyone at #aeasea take selfies and it broke the wifi 😛 oops#selfielove + #perfmatters https://t.co/6CBJJW3jKG
— Una 🇺🇦 (@Una) April 4, 2017