frontend-interview-questions

1. How do you define and enforce a performance budget for a React application?

Answer:

A performance budget is a set limit on key performance metrics. I define it early based on business needs and target devices using metrics like:

Enforcement tools:


performance: {
  maxEntrypointSize: 250000,
  maxAssetSize: 250000,
},


2. What’s your approach to auditing a React app against a performance budget during development?

Answer:

I use automated and manual tools in dev workflows:

Integrate metrics into PR reviews to ensure accountability.


3. How do you balance feature development with maintaining a performance budget in a React project?

Answer:

Balance through guardrails and priorities :

I advocate for performance as a non-functional requirement , not an afterthought.


4. What’s your strategy for optimizing third-party scripts within a performance budget?

Answer:

  1. Audit necessity of each script (use only what adds value).
  2. Load scripts asynchronously or defer :
<script src="chat.js" async></script>
  1. Move to server-side integrations (e.g., analytics proxy) when possible.
  2. Use Web Workers to isolate heavy work off the main thread.
  3. Leverage Subresource Integrity (SRI) and preconnect for faster delivery.


5. How do you integrate performance budget checks into a CI/CD pipeline for a React app?

Answer:

lighthouse-ci:
  script: lhci autorun

"scripts": {
  "size-check": "size-limit"
}


6. What’s your approach to optimizing images and assets in a React app to meet a performance budget?

Answer:


{
  loader: 'image-webpack-loader',
  options: { mozjpeg: { progressive: true } }
}


7. How do you measure and improve Time to Interactive (TTI) in a React application?

Answer:


const HeavyComponent = React.lazy(() => import('./Heavy'));


8. What’s your process for identifying and eliminating render-blocking resources in a React app?

Answer:

  1. Audit with Lighthouse/DevTools for blocked critical paths.
  2. Defer or preload fonts and styles:
<link rel="preload" as="style" href="styles.css" />
  1. Minimize and inline critical CSS .
  2. Load non-critical JS with defer or async.

Webpack plugins like mini-css-extract-plugin + critical CSS extractors help automate this.


9. How do you educate a team on adhering to a performance budget in a React codebase?

Answer:


10. What’s your approach to maintaining a performance budget as a React app scales over time?