You are building a large-scale React application and want to ensure that users only download the code for the components they are currently viewing. Which technique would best achieve this?
- Code splitting with React Suspense and React.lazy()
- Minification and gzip compression
- Pre-rendering the entire application on the server-side
- Using a Content Delivery Network (CDN) for all components
Code splitting with React Suspense and React.lazy() is a technique that allows you to split your code into smaller chunks and load only the components needed for the current view. This helps reduce initial load times and improves performance. Minification and gzip compression optimize code size but don't address dynamic loading. Pre-rendering on the server-side enhances SEO and initial load, but it doesn't load code dynamically. A CDN helps with delivery but doesn't handle dynamic loading.
Loading...
Related Quiz
- In a React application that uses Websockets for real-time notifications, users complain that they sometimes miss notifications. Which approach would best ensure reliable delivery of notifications?
- In Apollo Client, the local cache that stores the results of fetched GraphQL queries is called ________.
- To ensure specificity in CSS Modules without using deep selectors, one could use the :global ______.
- Why ReactDOM is separated from React?
- What is the primary benefit of lazy loading components in a React application?