Lost in calculation

As well as her personal site, wordridden.com, Jessica also has a professional site, lostintranslation.com.

Both have been online for a very long time. Jessica’s professional site pre-dates the Sofia Coppola film of the same name, which explains how she was able to get that domain name.

Thanks to the internet archive, you can see what lostintranslation.com looked like more than twenty years ago. The current iteration of the site still shares some of that original design DNA.

The most recent addition to the site is a collection of images on the front page: the covers of books that Jessica has translated during her illustrious career. It’s quite an impressive spread!

I used a combination of CSS grid and responsive images to keep the site extremely performant. That meant using a combination of the picture element, source elements, srcset attributes, and the sizes attribute.

That last part always feels weird. I have to tell the browser what sizes the images will displayed at, which can change depending on the viewport width. But I’ve already given that information in the CSS! It feels weird to have to repeat that information in the HTML.

It’s not just about the theoretical niceties of DRY: Don’t Repeat Yourself. There’s the very practical knock-on effects of having to update the same information in two places. If I update the CSS, I need to remember to update the HTML too. Those concerns no longer feel all that separate.

But I get it. Browsers use a look-ahead parser to start downloading images as soon as possible, so I understand why I need to explicitly state what size the images will be displayed at. Still, it feels like something that a computer should be calculating, not something for a human to list out by hand.

But wait! Most of the images on that page also have a loading attribute with a value of “lazy”. That tells browsers they don’t have to download the images immediately. That sort of negates the look-ahead parser.

That’s why the HTML spec now includes a value for the sizes attribute of “auto”. It’s only supposed to be used in conjunction with loading="lazy" (otherwise it means 100vw).

Browser makers are on board with this. You can track the implementation progress for Chromium, WebKit, and Firefox.

I would very much like to see this become a reality!

Have you published a response to this? :

Responses

5 Shares

# Shared by Luke Dorny on Monday, November 20th, 2023 at 4:17pm

# Shared by Krijn Hoetmer on Monday, November 20th, 2023 at 4:17pm

# Shared by Zach Leatherman on Monday, November 20th, 2023 at 4:17pm

# Shared by Eric Portis on Monday, November 20th, 2023 at 4:17pm

# Shared by Simon Praetorius on Tuesday, November 21st, 2023 at 1:07am

5 Likes

# Liked by Luke Dorny on Monday, November 20th, 2023 at 4:17pm

# Liked by Eric Portis on Monday, November 20th, 2023 at 4:17pm

# Liked by Zach Leatherman on Monday, November 20th, 2023 at 4:17pm

# Liked by John Kemp-Cruz on Monday, November 20th, 2023 at 7:06pm

# Liked by Timo Tijhof on Thursday, November 23rd, 2023 at 2:39pm

Related posts

Accessibility testing

It’s not just about finding the issues—it’s about finding the issues at the right time.

Making the website for Research By The Sea

Having fun with view transitions and scroll-driven animations.

Pickin’ dates on iOS

Mobile Safari doesn’t support the min and max attributes on date inputs.

Progressive disclosure with HTML

The `details` element is like the TL;DR of markup.

Three attributes for better web forms

Better UX through better HTML: inputmode, enterkeyhint, and autocomplete.

Related links

Standing still - a performance tinker | Trys Mudford

What Trys describes here mirrors my experience too—it really is worth occasionally taking a little time to catch the low-hanging fruit of your site’s web performance (and accessibility):

I’ve shaved nearly half a megabyte off the page size and improved the accessibility along the way. Not bad for an evening of tinkering.

Tagged with

How To Improve Largest Contentful Paint for Faster Load Times - Calibre

A no-nonsense checklist of good performance advice from Karolina.

Tagged with

AVIF has landed - JakeArchibald.com

There’s a new image format on the browser block and it’s very performant indeed. Jake has all the details you didn’t ask for.

Tagged with

The Crushing Weight of the Facepile—zachleat.com

Using IntersectionObserver to lazy load images—very handy for webmention avatars.

Tagged with

Reducing motion with the picture element

Here’s a clever tiny lesson from Dave and Brad: you can use prefers-reduced-motion in the media attribute of the source element inside picture.

Tagged with

Previously on this day

7 years ago I wrote An associative trail

Intertwingled hyperlinks.

16 years ago I wrote Rating and launching

Rate My Area has launched.

21 years ago I wrote La Cucina Bolognese

I’ve been quite a busy bee lately, working over at Message with my head full of objects, arrays, functions, queries and other inhabitants of the PHP world.

22 years ago I wrote MacExpo 2002

I’m off to London to check out the goodies at the MacExpo.

23 years ago I wrote Ice Mold

I smold, you smold, we all smold for ice mold.

23 years ago I wrote The Czars

I went out last night to see a band called The Czars. Actually, I saw two fifths of the band: the singer and guitarist are doing a little mini-tour ‘round England.

23 years ago I wrote Osama's Nuclear Plans Half-Baked

Here’s a tale of the blind leading the blind.