June 29th, 2024

Enhancing New York Times Web Performance with React 18

The New York Times upgraded to React 18 for better performance and new features like Concurrent Mode and server-side rendering. Challenges with "embedded interactives" were overcome, leading to improved website performance.

Read original articleLink Icon
Enhancing New York Times Web Performance with React 18

The New York Times recently upgraded its website to React 18, aiming to enhance performance and access new features. The upgrade introduced Concurrent Mode for smoother rendering, automatic batching for optimized performance, and new features like server-side rendering and streaming updates. The performance gains were crucial for improving Interaction to Next Paint scores, a key metric for search engine ranking. The migration process involved removing deprecated dependencies, upgrading major dependencies, and integrating React 18 functionalities like createRoot and hydrateRoot. However, challenges arose with highly trafficked content called "embedded interactives," impacting the React upgrade. These interactives, rendered server-side with dangerouslySetInnerHTML, posed issues due to React 18's stricter hydration mismatch requirements. The team navigated these challenges by adjusting script execution and ensuring correct script load ordering. Despite the hurdles, the React 18 upgrade brought significant performance improvements and opened doors to future enhancements for The New York Times website.

Related

AI-powered conversion from Enzyme to React Testing Library

AI-powered conversion from Enzyme to React Testing Library

Slack engineers transitioned from Enzyme to React Testing Library due to React 18 compatibility issues. They used AST transformations and LLMs for automated conversion, achieving an 80% success rate.

Understanding React Compiler

Understanding React Compiler

React's core architecture simplifies app development but can lead to performance issues. The React team introduced React Compiler to automate performance tuning by rewriting code using AST, memoization, and hook storage for optimization.

Understanding React Compiler

Understanding React Compiler

React's core architecture simplifies development but can lead to performance issues. The React team introduced the React Compiler to automate performance tuning by rewriting code. Transpilers like Babel convert JSX for efficiency. Compilers, transpilers, and optimizers analyze and produce equivalent code. React Compiler enhances functionality using Abstract Syntax Trees, memoization, and hook storage for optimized performance.

Show HN: OSS React Components for Dashboards

Show HN: OSS React Components for Dashboards

Installing Tremor Raw for React v18.2.0+ with Tailwind CSS v3.4+. Compatible with Next.js, Vite, Remix. Resources: Tremor Blocks, Figma UI Kit, Remix Icon. Footer: bug reporting, Tremor Labs, Inc. rights.

It's not just you, Next.js is getting harder to use

It's not just you, Next.js is getting harder to use

Next.js 13 introduces App Router with Server Components and enhanced caching, but users face challenges in utilizing features like Layouts and cookies. The shift to a more complex framework raises debates on balancing functionality and user-friendliness.

Link Icon 5 comments
By @xnx - 5 months
App-ifying articles is an unfortunate path many sites have gone down. Islands of interactivity are great for special cases (games, some charts), but delivering a few KB of text via an application framework is overkill.
By @ozzcer - 5 months
As a dev that has never worked with react its, interesting, to see react '18' introducing fixes to problems that have not been issues before. I've used angular, straight SSR from PHP / node.js / .net and never suffered from 'screen jank' or huge culumative layout shift issues. Not sure we should celebrate the fixing of issues that shouldn't have ever been a problem for a site that just renders text and images.
By @8organicbits - 5 months
I wish they'd consider adding lighter pages. Compare the load time of a NYT page [1] to a text NPR page [2]. I'm seeing 5.5 seconds vs 600 ms. I think the latter is easier to read as well.

[1] https://www.nytimes.com/2024/06/29/us/politics/biden-donors-...

[2] https://text.npr.org/g-s1-6773