1. 程式人生 > >A Pinterest Progressive Web App Performance Case Study

A Pinterest Progressive Web App Performance Case Study

Experience using Redux

Pinterest use normalizr (which normalizes nested JSON according to a schema) for all of their API data. This is viewable from the Redux DevTools:

The downside to this process is that denormalization is slow so they ended up heavily relying on reselect’s selector pattern for memoizing denormalization during renders. They also always denormalize at the lowest level possible to ensure individual updates don’t cause large re-renders.

As an example, their grid item lists are just Pin IDs with the Pin component denormalizing itself. If there are changes to any given Pin, the full grid does not have to re-render. The trade-off is that there are a lot of Redux subscribers in the Pinterest PWA, though this hasn’t resulted in noticeable perf issues.

Caching assets with Service Workers

Pinterest use the Workbox libraries for generating and managing their Service Workers:

Today, Pinterest cache any JavaScript or CSS bundles using a cache-first strategy and also cache their user-interface (the application shell).

In a cache-first setup, if a request matches a cache entry, respond with that. Otherwise try to fetch the resource from the network. If the network request succeeds, update the cache. To learn more about caching strategies with Service Worker, read
Jake Archibald’s Offline Cookbook
.

They define a precache for the initial bundles loaded by the application shell (webpack’s runtime, vendor and entryChunks) too.

As Pinterest is a site with a global presence, supporting multiple languages, they also generate a per-locale Service Worker configuration so they can precache locale bundles. Pinterest also use webpack’s named chunks to precache top-level async route bundles.

This work was rolled out in several smaller, iterative steps.

  • 1st: Pinterest’s Service Worker only did runtime caching of scripts lazy-loaded on demand. This was to take advantage of V8’s code caching, helping skip some of the parse/compile cost on repeat views so they can load quicker. Scripts served from Cache Storage where a Service Worker is present can eagerly opt into code caching as there’s a good chance the browser knows the user will end up using these resources on repeat views.

相關推薦

A Pinterest Progressive Web App Performance Case Study

Experience using ReduxPinterest use normalizr (which normalizes nested JSON according to a schema) for all of their API data. This is viewable from the Red

Seriously, though. What is a progressive web app?

I’ve been familiar with the “progressive web app” (PWA) concept for a while now. But there’s always been an itch in the back of my mind about it.I’ve been

Progressive Web App(PWA)介紹

Progressive Web App(PWA)背景介紹 很多人似乎都認為Web,應用永遠不會與本機競爭,移動應用程式的可靠性速度和使用者參與,很難建立一個他們的商業案例。 你知道嗎?你知道他們曾經是對的,但有兩件事情發生了變化。 首先,事實證明,大多數人在購買手機時購買了大部分應用程式,或者不久之後大

Upgrading Ele.me to Progressive Web App

Huge JavaScript Re-Startup CostAccording to the profile, most of the time (900ms) before hitting the first paint is spent on evaluating JavaScript. Half is

Creating a basic CRUD web app with Vue, Vuetify, and Butterfly Server .NET

Creating a basic CRUD web app with Vue, Vuetify, and Butterfly Server .NETNearly every web app has to handle basic CRUD operations (Create, Read, Update, a

PWA(Progressive Web App)入門系列:(五)Web Worker

前言 在說Service Worker前有必要說一下Web Worker,因為Service Worker本身就屬於Web Worker的延伸,大部分功能也是基於Web Worker進行的擴充套件。 背景 眾所周知,JavaScript引擎是以單執行緒排程的方式進行,我們無法

PWA(Progressive Web App)入門系列:(四)Promise

前言 這一章說一下ES6的Promise物件。為什麼要在PWA系列的文章中講Promise呢?因為PWA中的許多技術API中都是以Promise返回的方式返回的,為了對後續章節中PWA技術API更好的理解,這裡就來說一個Promise物件。 Promise出現的背景 在Jav

PWA(Progressive Web App)入門系列:(三)PWA關鍵技術Manifest

前言 前面說過,讓Web App能夠達到Native App外觀體驗的主要實現技術就是PWA中的manifest技術,本章會詳細說明manifest的實現,及各個引數的具體含義,還將瞭解如何定義Web App的啟動圖示、啟動樣式等。 簡介 manifest是一種簡單的json

PWA(Progressive Web App)入門系列:(二)相關準備

前言 在上一章中,對PWA的相關概念做了基本介紹,瞭解了PWA的組成及優勢。為了能夠更快的進入PWA的世界,這一章主要對在PWA開發中,需要注意的問題,執行的環境及除錯工具做介紹說明。 瀏覽器要求 因為目前各瀏覽器對於PWA的支援度各不一樣,在這裡為了對PWA有更好的體驗及使

PWA(Progressive Web App)入門系列:(一)PWA簡介

前言 PWA做為一門Google推出的WEB端的新技術,好處不言而喻,但目前對於相關方面的知識不是很豐富,這裡我推出一下這方面的入門教程系列,提供PWA方面學習。 什麼是PWA PWA全稱Progressive Web App,直譯是漸進式WEB應用,是 Goog

啟動weblogic報錯:string value '2.4' is not a valid enumeration value for web-app-versionType in namespace http://java.sun.com/xml/ns/javaee

-a xsd not app b- 1.0 ring encoding ont 啟動報錯: 原因:有人改動了web.xml的頭 解決方法: 在web.xml中修改擡頭為: <?xml version="1.0" encoding="UTF-8"?> <we

Microsoft Azure Tutorial: Build your first movie inventory web app with just a few lines of code

tro options core any call jpg should nav lines Editor’s Note: The following is a guest post from Mustafa Mahmutovi?, a Microsoft Student

I built a web app that help events organizers build mobile apps

Hi there.I am looking for someone to test my app, it's a small web app prototype to help event organizers build cross platform mobile apps, the main concep

On the power of technologic icebreakers, a UX case study on how adults and teens could write…

On the power of technologic icebreakers, a UX case study on how adults and teens could write stories together with hashtags.Designing for familiesFor my fi

It’s more than the music- a UX case study

It’s more than the music- a UX case studyNowadays, we can do anything from our cellphones. We can buy groceries, connect with people across the world, and

Case Study: How Research Simplified My UX Design for Healthcare App

How Research Simplified UX Design for Healthcare AppRegardless of your vision of the product and your confidence in its greatness, the future of it depends

Community Land Trust — A UI Design Case Study

04 | DesignStyle GuideThe style guide consists of the different branding assets that we’re curated throughout the whole project. We used the logo to create

Ask HN: Verifying a web app pointing to a specific deployment/commit

I've looked at ways to verify whether a specific deployment is signed and associated with a specific commit hash/deployment, but how do you verify (as a cl

ResumeMaker.Online — a UX case study

Months ago, when my sister asked me for help with her resume, I was too busy to design one from scratch. I searched online for a resume creator to quickly

Simplified GitHub Login for a Ruby Web App

You know what OAuth login is, right? It’s when your users click “login” and get redirected to Facebook, Twitter, Google, or some other website which then i