Article Complete
AIM
Pinterest Moves Away from JavaScript for Carousels
Pinterest Moves Away from JavaScript for Carousels
CSSing improved.

Pinterest Moves Away from JavaScript for Carousels

The company has replaced 2,000 lines of JavaScript with 200 lines of native CSS code.

Published Updated

Key takeaways

  • Pinterest replaced 2,000 lines of JavaScript with 200 lines of CSS for carousels.
  • The switch to native CSS significantly improved carousel performance and user experience.
  • This change reduced code complexity and maintenance challenges for Pinterest's carousels.
  • Browser-native CSS primitives like scroll snapping enhanced UI smoothness.
5 min

Pinterest has replaced its legacy JavaScript-based carousel system with native CSS implementations, reducing code complexity and improving performance. This was recently highlighted by Google on their ‘Chrome for Developers’ account on X. 

The change moves a core UI component—used widely across feeds, search, and shopping experiences—from a heavily customised JavaScript setup to browser-native CSS primitives such as scroll snapping and markers.

The earlier system had evolved over time into a complex codebase spanning nearly 2,000 lines of JavaScript, built and modified by multiple teams. 

Engineers said this made the component difficult to maintain and introduced performance issues, including noticeable lag during interactions. “You feel the jank in every scroll,” said Calvin Chhour, senior software engineer at Pinterest, in a YouTube video.


Pinterest engineers said an initial prototype of the CSS-based carousel was built quickly and showed immediate improvements in smoothness, as UI interactions were no longer blocked on the browser’s main thread.

By rebuilding the carousel using CSS, Pinterest reduced the implementation to around 200 lines of code, a 90% drop. “We were able to reduce 2,000 lines of JavaScript to 200 lines of CSS,” Chhour said.

The company tested the new implementation through A/B experiments, running a portion of users on the new experience while others remained on the older system. According to Pinterest, the updated approach delivered measurable improvements in both performance and user experience.

“We also saw 15% improvements in just page load time in general,” Anuja Shah, an engineering manager at Pinterest, said in the video. The company subsequently rolled out the new carousel to its full user base.

Pinterest engineers said the shift to CSS also enables smoother interactions and opens up new possibilities for animations and transitions using native browser capabilities, without relying on heavier JavaScript libraries.

The company added that it has since extended the CSS-based carousel across multiple product surfaces, working with teams across the home feed, search, shopping, and boards to replace existing implementations.

Membership

Stay ahead with AI insights.

Unlimited access to premium articles, exclusive analysis, and the stories shaping India's AI economy.

Subscribe now

AIM Americas

1190 Miraloma Way Suite P, Sunnyvale, CA 94085

AIM India

1st Floor, Sakti Statesman, Bellandur, Bengaluru – 560103

Β© 2026 AIM. All rights reserved.