Ben Forshey

A Red-Letter Day for Service Workers

written January 25th, 2018

Safari Gets Service Workers

Apple, much like Microsoft, hasn’t exactly rushed to implement service workers. I’ve been keeping an eye on Is Service Worker Ready and Can I Use for a while now, hoping to see an implemention coming in either browser. Well, today is that day! As of Safari 11.1 (coming in macOS High Sierra 10.13.4 and iOS 11.3, according to Ricky Mondello of Apple), Safari supports service workers!

Why Service Workers Matter

Like all web workers, service workers run on a separate thread. Though JavaScript uses a single-threaded event loop to execute its instructions, by offloading operations onto another thread, it can take advantage of your computer’s multi-threaded capabilites by allowing limited communication between the two JavaScript threads.

Google’s Progressive Web Apps Training docs summarize service workers as being made for “intercepting network requests, caching or retrieving resources from the cache, and delivering push messages.” Since speed matters—a mantra you’ll often hear me repeat—the low-hanging fruit of service workers is to address the most fragile part of the web experience—the internet connection.

By caching your app shell, or even your entire website, you can give your site’s visitors a fast, durable user experience, regardless of the quality (or existence) of their internet connection. It’s pretty great stuff!

Other Safari 11.1 News

Where to go From Here

Nolan Lawson delivered a great talk on web workers and service workers at BrazilJS 2016. Check it out and get inspired!