Modernizing the Pinterest carousel: 90% less code with native CSS
Key Takeaways
Modernizing the Pinterest carousel with native CSS, reducing code by 90% and improving page load time by 15%, using CSS carousels and View Transitions.
Full Transcript
[music] >> How do you build a web that inspires 600 million users? My name is Calvin. I'm a senior software engineer at Pinterest. I'm [music] tech lead for web on the close-up experience team. I'm Anuja. I'm the engineering manager for the close-up experience team. [music] Carousels are pretty core to the use case of Pinterest. We use carousels because it kind of is a good way to mix things up, break up the monotony of some of the other layouts. It [music] started off with maybe one team building the carousel over the few years. It probably became this Frankenstein of 2,000 lines of code with these different little flavors [music] from all different teams that were added, which was getting very difficult to maintain. When I was swiping through these carousels, it was like clunky, noticeable lag. You feel the jank in every scroll, and I heard there's a CSS carousel coming out. I was like, "Okay, well, I know [music] where we can use that." Converting the close-up carousels from JavaScript to CSS was pretty easy. The initial attempt didn't take too much work, a week at most. When I first prototyped it, it was way smoother right away. All the bits and pieces of the carousel were no longer blocked on the main thread. What we wanted to do is run AB tests so we can grab some metrics and see how it was actually performing. We run a small >> [music] >> portion of our user base on the new experience, and the rest still using the old [music] code, which was the 2,000 lines of custom carousel code. >> We saw massive performance gains as well as some engagement wins as well. We were able to reduce 2,000 lines of JavaScript to [music] 200 lines of CSS, which is a 90% drop. >> We also saw 15% improvements in just page [music] load time in general. Once we saw that, we decided to ship the experiment all the way to 100%. The next step was trying to [music] replace any of the existing use cases of the carousel on the Pinterest webpage. [music] We worked with the home feed team, the shop the look team, the search team, the boards team. >> Now, when a user goes to the carousel, there's not going to be jank. Everything is really performing all the time. There are so many new experiences that are going to be possible with CSS, so it's kind of exciting to see the direction being set. I was experimenting with other features like view transitions. Before, if you wanted to get animation like this, you'd have to bring in some other heavier libraries. We don't do heavy libraries at Pinterest. We just live without the experience. Trying it out for the first time is like very easy. Drop in property name CSS, and it was working. And [music] you have to call start view transition. It's really cool to see the native animations with not too much work. [music] We've been able to truly experiment and innovate on web this year. The web is capable of anything. Whatever you imagine, you can [music] build it on the web.
Original Description
How do you build a web that inspires 600 million users? At Pinterest, the "Close Up" experience is core to how users discover ideas. But over time, the JavaScript powering carousel experience became a patchwork of 2,000 lines of code—resulting in noticeable lag and "jank" for users.
In this video, Pinterest engineers Calvin and Anuja walk through how they swapped legacy JavaScript for modern CSS carousels and View Transitions. The results? A 90% reduction in code, a 15% improvement in page load time, and a smoother, native-feeling UI.
Chapters:
[0:07] Inspiring 600 Million Users
[0:10] Meet the team: Engineering at Pinterest
[0:21] The legacy carousel: 2,000 Lines of JavaScript
[0:49] The Experiment: Converting to CSS carousel
[1:22] Results: 90% less code, 15% less load time.
[1:36] Scaling success everywhere
[2:03] View Transitions: Smooth animations are now possible
📚Resources:
Make accessible carousels → https://goo.gle/4aTpGtc
Carousels with CSS → https://goo.gle/3YuWhOv
Scoped View Transitions → https://goo.gle/3XuZMUX
View Transition API → https://goo.gle/3MzVngY
Watch more “Re-Imagine the web” → https://goo.gle/re-imagine-the-web
Subscribe to Chrome for Developers → https://goo.gle/ChromeDevs
#Chrome #Pinterest #webui
Products Mentioned: Chrome, Pinterest, web platform, web development, CSS, CSS carousels, CSS primitives, View Transitions
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Chrome for Developers · Chrome for Developers · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
Web Directions Code 2015 round up
Chrome for Developers
Maintainable Code - HTTP203
Chrome for Developers
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
The Guardian - Supercharged
Chrome for Developers
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
The Future of JavaScript - HTTP203
Chrome for Developers
Data Binding 101 -- Polycasts #28
Chrome for Developers
The Guardian part 2 - Supercharged
Chrome for Developers
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
Binding to Objects -- Polycasts #30
Chrome for Developers
Player FM - Supercharged
Chrome for Developers
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
Jake Beats Wikipedia - HTTP203
Chrome for Developers
Supercharged Observers! -- Polycasts #32
Chrome for Developers
Jai's Web blog - Supercharged
Chrome for Developers
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
Google+ Performance Improvement Comparison
Chrome for Developers
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
Binding to Arrays -- Polycasts #35
Chrome for Developers
HTTP2 - HTTP203
Chrome for Developers
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
Call For Submissions - Supercharged
Chrome for Developers
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
Highlights from Chrome Dev Summit 2015
Chrome for Developers
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers
More on: Frontend Performance
View skill →Related Reads
📰
📰
📰
📰
I built a landing page with Three.js, vanilla JS, and zero frameworks — here's what I learned
Dev.to · Ayush Shekhar
Part 1: Why I Rarely Use useEffect Anymore (and what I use instead)
Dev.to · Alejandro
HTML Canvas Cheat Sheet for Pixel Art & Image Effects
Dev.to · lemon
Draw Pixel Art with Vanilla JS — A Step-by-Step Guide
Dev.to · lemon
🎓
Tutor Explanation
DeepCamp AI