YouTube’s mission is to give everyone a voice and show them the world. But without an internet connection, users had to put the conversation on pause.
To make sure Premium users can watch anytime, anywhere, YouTube built a Progressive Web App (PWA) to deliver an immersive video experience across browsers, devices, and form factors — even offline.
PWAs allow developers to introduce modern APIs to new and existing apps, combining the rich capabilities of platform apps with the extensive reach of web apps. Here’s how YouTube’s team of developers created a PWA with secure offline playback and made the experience even better on Chromebooks.
Before YouTube launched its PWA, Premium users on Chrome OS had to use the Android app if they wanted to watch videos offline. YouTube wanted its web users to have access to these capabilities so they could watch videos no matter where or how they tune in. Building the installable PWA and setting up offline playback took a lot of learning and experimenting.
YouTube already had a service worker with push notifications in place, but it didn’t include a fetch handler. The YouTube team was also concerned that adding one could break the site for users, so to prevent site crashes, the team created a no operation service worker that brings users back to a browser-like default site.
To make sure users always have the most up-to-date version of YouTube, the team made it so the PWA always served from the network and only fell back to the cache when needed. They also needed to get the service worker’s latency as close to zero as possible, which they achieved with this network-first caching approach and use of Navigation Preloads. The team also introduced service worker monitoring to detect breakages.
After the team got the service worker to cache the core application, they were ready to set up offline playback.
First, everything on the back end that assumed users were always online needed to be adjusted. Then, the team had YouTube’s custom video player download the encrypted bytes for a video and store them locally using the IndexedDB API. This keeps offline playback secure while allowing the ability to store even multiple large video files.
Chromebook users were ideal candidates to test these updates with because they all have the latest APIs — so the YouTube team was able to run experiments with real users. The team started by optimizing the app for Chrome OS with several new features:
- New gestures with touch support in addition to mouse and keyboard interactions
- Double-tap to seek in the player
- Voice search
Watching videos offline on laptops and hybrid devices was one of the top requested features from YouTube Premium users, and the YouTube team has already heard great feedback about the offline experience. With the new PWA, YouTube Premium users can get nonstop access to the content they love — even when they’re on the go. A user can download their favorite creator’s latest videos to watch on their Chromebook on a plane, in a coffee shop, or anywhere they might not have a stable internet connection.
And now, the PWA is quickly becoming Chromebook users’ primary destination for YouTube content.
What’s the best part about designing the web app for Chrome OS? Because Chrome’s APIs aren’t OS-specific, the experience is scalable across even more devices and browsers.
Instead of having to refine the app for different user segments, creating a PWA for Chrome OS let the YouTube team deliver a reliable, rich, and app-like experience.
YouTube internal data. ↩︎