Modernizing the Pinterest carousel: 90% less code with native CSS

Matthew Berman · Intermediate ·🌐 Frontend Engineering ·4mo ago

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 Polymer Performance Patterns (The Polymer Summit 2015)
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
2 Polymer Power Tools (The Polymer Summit 2015)
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
3 Chrome Dev Summit 2014 – Chrome Case Studies
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
4 Web Directions Code 2015 round up
Web Directions Code 2015 round up
Chrome for Developers
5 Maintainable Code - HTTP203
Maintainable Code - HTTP203
Chrome for Developers
6 iron-ajax… wat?! -- Polycasts #26
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
7 The Guardian - Supercharged
The Guardian - Supercharged
Chrome for Developers
8 ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
9 #AskPolymer: Rob answers all the questions ever -- Polycasts #27
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
10 The Future of JavaScript - HTTP203
The Future of JavaScript - HTTP203
Chrome for Developers
11 Data Binding 101 -- Polycasts #28
Data Binding 101 -- Polycasts #28
Chrome for Developers
12 The Guardian part 2 - Supercharged
The Guardian part 2 - Supercharged
Chrome for Developers
13 The Future of Web Audio: with Chris Wilson and Chris Lowis
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
14 Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
15 Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
16 #AskPolymer: How do you make the show? -- Polycasts #29
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
17 Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
18 Binding to Objects -- Polycasts #30
Binding to Objects -- Polycasts #30
Chrome for Developers
19 Player FM - Supercharged
Player FM - Supercharged
Chrome for Developers
20 Where’s the Designer? #AskPolymer -- Polycasts #31
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
21 Jake Beats Wikipedia - HTTP203
Jake Beats Wikipedia - HTTP203
Chrome for Developers
22 Supercharged Observers! -- Polycasts #32
Supercharged Observers! -- Polycasts #32
Chrome for Developers
23 Jai's Web blog - Supercharged
Jai's Web blog - Supercharged
Chrome for Developers
24 Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
25 What about internationalization? #AskPolymer -- Polycasts #33
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
26 Developing for Billions (Chrome Dev Summit 2015)
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
27 Google+ Performance Improvement Comparison
Google+ Performance Improvement Comparison
Chrome for Developers
28 Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
29 Progressive Web Apps (Chrome Dev Summit 2015)
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
30 Instant Loading with Service Workers (Chrome Dev Summit 2015)
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
31 Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
32 Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
33 Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
34 Polymer - State of the Union (Chrome Dev Summit 2015)
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
35 Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
36 Introduction to RAIL (Chrome Dev Summit 2015)
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
37 DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
38 RAIL in the real world (Chrome Dev Summit 2015)
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
39 #ChromeDevSummit talks are up - W00T! -- Polycast #34
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
40 V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
41 Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
42 Owning your performance: RAIL (Chrome Dev Summit 2015)
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
43 HTTP/2 101 (Chrome Dev Summit 2015)
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
44 Leadership Panel (Chrome Dev Summit 2015)
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
45 Build Processes, Totally Tooling Tips (S2, Ep 5)
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
46 Accessibility (Chrome Dev Summit 2015)
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
47 Binding to Arrays -- Polycasts #35
Binding to Arrays -- Polycasts #35
Chrome for Developers
48 HTTP2 - HTTP203
HTTP2 - HTTP203
Chrome for Developers
49 Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
50 Call For Submissions - Supercharged
Call For Submissions - Supercharged
Chrome for Developers
51 Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
52 Testing AJAX with Web Component Tester -- Polycasts #37
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
53 Slack: Extended Xmas Special - Supercharged
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
54 Browser testing with Travis & Sauce Labs -- Polycasts #38
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
55 Optimize for production with Vulcanize -- Polycasts #39
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
56 Highlights from Chrome Dev Summit 2015
Highlights from Chrome Dev Summit 2015
Chrome for Developers
57 Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
58 Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
59 How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
60 Colors – DevTools Tonight #0 (Pilot)
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers

Learn how Pinterest engineers modernized their carousel experience using native CSS, reducing code by 90% and improving page load time by 15%. Discover how to optimize your web development projects with CSS carousels and View Transitions.

Key Takeaways
  1. Identify areas for code optimization in your web project
  2. Convert legacy JavaScript to modern CSS carousels
  3. Implement View Transitions for smooth animations
  4. Test and measure the impact of code changes on page load time and UI smoothness
  5. Scale successful optimizations across your web application
💡 Using native CSS carousels and View Transitions can significantly reduce code complexity and improve web page performance.

Related Reads

Up next
Elementor Angie Ai Plugin Tutorial
Quick Tips - Web Desiign & Ai Tools
Watch →