Speculation rules and fears

After I wrote positively about the speculation rules API I got an email from David Cizek with some legitimate concerns. He said:

I think that this kind of feature is not good, because someone else (web publisher) decides that I (my connection, browser, device) have to do work that very often is not needed. All that blurred by blackbox algorithm in the browser.

That’s fair. My hope is that the user will indeed get more say, whether that’s at the level of the browser or the operating system. I’m thinking of a prefers-reduced-data setting, much like prefers-color-scheme or prefers-reduced-motion.

But this issue isn’t something new with speculation rules. We’ve already got service workers, which allow the site author to unilaterally declare that a bunch of pages should be downloaded.

I’m doing that for Resilient Web Design—when you visit the home page, a service worker downloads the whole site. I can justify that decision to myself because the entire site is still smaller in size than one article from Wired or the New York Times. But still, is it right that I get to make that call?

So I’m very much in favour of browsers acting as true user agents—doing what’s best for the user, even in situations where that conflicts with the wishes of a site owner.

Going back to speculation rules, David asked:

Do we really need this kind of (easily turned to evil) enhancement in the current state of (web) affairs?

That question could be asked of many web technologies.

There’s always going to be a tension with any powerful browser feature. The more power it provides, the more it can be abused. Animations, service workers, speculation rules—these are all things that can be used to improve websites or they can be abused to do things the user never asked for.

Or take the elephant in the room: JavaScript.

Right now, a site owner can link to a JavaScript file that’s tens of megabytes in size, and the browser has no alternative but to download it. I’d love it if users could specify a limit. I’d love it even more if browsers shipped with a default limit, especially if that limit is related to the device and network.

I don’t think speculation rules will be abused nearly as much as client-side JavaScript is already abused.

Have you published a response to this? :

Responses

Barry Pollard

@adactio FYI, speculation rules DOES honour save-data (though sadly usage of that is low) and also the Settings->Performance->Preloading settings.

There are also various other checks we’ve use:https://www.youtube.com/watch?v=bSua9vMdrNM&t=1317s

We think that the user-agent being in control of this API is in fact BETTER than doing similar functionality with `<link rel>`, fetch, serviceworkers or similar.

From fast loading to instant loading

5 Likes

# Liked by Ana Rodrigues on Thursday, May 23rd, 2024 at 1:53pm

# Liked by Ben Royce 🇺🇸 🇺🇦 on Thursday, May 23rd, 2024 at 2:27pm

# Liked by 高文偉 on Thursday, May 23rd, 2024 at 2:28pm

# Liked by Royce Williams on Thursday, May 23rd, 2024 at 2:28pm

# Liked by AdamSedwick on Thursday, May 23rd, 2024 at 3:59pm

Related posts

Opening up the AMP cache

A proposal to tackle the injustice of Google AMP pages receiving preferential treatment in Google search results.

Trust

I’m trying to understand why developers would trust third-party code more than a native browser feature.

Service worker weirdness in Chrome

Debugging an error message.

Apple’s attack on service workers

Kiss your service workers goodbye on iOS.

Navigation preloads in service workers

A little performance boost for your network-first service worker strategy.

Related links

Need to Catch Up on the AMP Debate? | CSS-Tricks

Funnily enough, I led a brown bag lunch discussion about AMP at work just the other day. A lot of it mirrored Chris’s thoughts here. It’s a complicated situation that has lots of people worried.

Tagged with

Every website and web app should have a service worker | Go Make Things

Needless to say, I agree with this sentiment.

I’ve worked with a lot of browser technology over the years. Service workers are pretty mind-blowing.

Tagged with

Tagged with

How to make MPAs that are as fast as SPAs | Go Make Things

The headline is a little misleading because if you follow this advice, your multi-page apps will be much much faster than single page apps, especially when you include that initial page load of a single page app.

Here’s a quick high-level summary of what I do…

  1. Serve pre-rendered, mostly static HTML.
  2. Inline everything, including CSS and JavaScript.
  3. Use mostly platform-native JavaScript, and as little of it as possible.
  4. Minify and gzip all the things.
  5. Lean heavily on service workers.

That’s an excellent recipe for success right there!

Tagged with

Add a Service Worker to Your Site | CSS-Tricks - CSS-Tricks

Damn, I wish I had thought of giving this answer to the prompt, “What is one thing people can do to make their website better?”

If you do nothing else, this will be a huge boost to your site in 2022.

Chris’s piece is a self-contained tutorial!

Tagged with

Previously on this day

4 years ago I wrote Speaking about sci-fi

Please join me and Steph Troeth for our Stay Curious event on June 16th.

5 years ago I wrote Integration

A2 _B2-_BAG A2 (3zGF C2

6 years ago I wrote Beyond

The hero’s journey meets documentation in Düsseldorf.

8 years ago I wrote Going offline at Indie Web Camp Düsseldorf

Making a better offline page.

10 years ago I wrote 100 words 062

Day sixty two.

21 years ago I wrote Came not so far for beauty

Ever have one of those dreams that are filled with a bizarre mish-mash of famous people in a familiar setting but doing things they wouldn’t normally do?

23 years ago I wrote Hei Hei

I’m taking off for the weekend.