Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Fundamentals
  1. 1.Introduction to Frontend System Design
  2. 2.Core Frontend Architecture Concepts
  3. 3.Client-Server Interaction Fundamentals
  4. 4.Basic Performance & Accessibility Considerations
  5. 5.State Management Basics & Data Flow
  6. 6.Advanced State Management & Global Stores
  7. 7.Component Libraries & Design Systems
  8. 8.Frontend Build Tools & Development Workflows
  9. 9.Advanced Performance Optimization Techniques
  10. 10.Data Fetching Strategies & Caching
  11. 11.Frontend Security Essentials
  12. 12.Micro-Frontend Architectures
  13. 13.Real-time Communication & WebSockets
  14. 14.Observability, Monitoring, & Logging
  15. 15.Offline-First & Progressive Web Apps (PWAs)
Frontend System Design Fundamentals
04

Frontend System Design · Lesson 4 of 15 · 4 min

Basic Performance & Accessibility Considerations

This is how you show you build for real users, not just for yourself. Get this right, and you demonstrate senior-level thinking.

After this lesson, you'll be able to explain the critical performance and accessibility trade-offs in a system design interview and justify your choices. These aren't afterthoughts; they are core architectural concerns.

Ship Less Code, Faster

The fastest code is the code you don't send. The initial load is your first impression, and a massive JavaScript bundle is the most common reason for a bad one.

Your primary tool here is code splitting. Instead of one giant bundle.js, you create smaller chunks that are loaded on demand. The most common strategy is route-based splitting. A user visiting /settings doesn't need the code for the /dashboard. Frameworks have built-in APIs for this, like React.lazy() or dynamic import() in Vue and Angular.

The second part of this is lazy loading assets. For a long page with many images, load only the ones in or near the viewport. Modern browsers make this trivial with the loading="lazy" attribute on <img> tags. For older browsers or more complex components (like a video player), you'd use the Intersection Observer API.

In an interview, when asked how to improve a slow-loading page, your first answer should be: "I'd start by analyzing the bundle. We can probably code-split by route and lazy-load below-the-fold components." This is a high-impact, low-effort answer.

Control Event Overload with Debounce and Throttle

Some browser events fire hundreds of times per second: resize, scroll, or even typing in an input. Attaching a heavy function to these events will kill performance. You control this with debouncing and throttling.

Debouncing waits for a pause in the event stream before executing the function. Think of a search bar: you don't want to fire an API request for every single keystroke. You wait until the user stops typing for, say, 300ms, and then you search.

Throttling ensures a function is executed at most once per a given time interval. Imagine tracking scroll position to trigger an animation. You don't need to know the position 60 times a second. Throttling it to run once every 100ms is more than enough and saves significant CPU cycles.

The trap: Candidates often mix them up. Remember:

  • Debounce: Wait for a pause.
  • Throttle: Enforce a cooldown.

You will likely be asked to implement one of these. Know the debounce function by heart. It's a classic closure and setTimeout problem.

function debounce<T extends (...args: any[]) => void>(func: T, delay: number) {
  let timeoutId: ReturnType<typeof setTimeout>;

  return function(this: any, ...args: Parameters<T>) {
    clearTimeout(timeoutId);
    timeoutId = setTimeout(() => {
      func.apply(this, args);
    }, delay);
  };
}

// Usage:
// const debouncedApiCall = debounce(fetchApiData, 500);
// searchInput.addEventListener('input', (e) => debouncedApiCall(e.target.value));

This implementation is simple and correct. It uses a closure to maintain a reference to timeoutId across calls. Each call clears the pending timeout and sets a new one, effectively resetting the "wait" period.

Build for Everyone with Accessibility (A11y)

Accessibility isn't a feature; it's a fundamental requirement for a robust UI. In a system design context, it means making architectural choices that enable, rather than hinder, an inclusive experience.

Start with semantic HTML. Use <button>, <nav>, <h1>, etc., for their intended purpose. This gives you a huge amount of accessibility for free. Screen readers and other assistive technologies understand native elements. A <div> with an onClick is not a button; it's not focusable by default, and it doesn't announce itself as a button.

When you can't use a native element (e.g., for a complex custom component like an autocomplete or a tree view), you use ARIA attributes. ARIA adds the missing semantics. For example, role="combobox" tells a screen reader that an input and a list work together as a single widget.

The trap: Overusing ARIA or using it incorrectly. "No ARIA is better than bad ARIA." If you have a <button>, you do not need to add role="button". The browser already knows. Only add ARIA to bridge the gap where HTML's semantics fall short.

Keyboard navigation is non-negotiable. All interactive elements must be reachable and operable using the Tab, Shift+Tab, Enter, and Space keys. Test your own work by unplugging your mouse. If you can't use your component, it's broken.

Finally, consider color contrast. Text must be readable against its background. Tools like Lighthouse or browser dev tools can check this for you automatically. This is a simple but critical check that demonstrates attention to detail.

When asked to design a component like a modal or a dropdown, your first few sentences should be about its accessibility. "For a modal, I'd ensure it traps focus so a keyboard user can't tab to elements behind it. I'd also make sure the Escape key closes it, and I'd use ARIA attributes like role="dialog" and aria-modal="true"." This immediately signals that you build professional-grade components.

Try it

Implement a useDebounce custom hook in a small React app. Create a search input that uses this hook to delay an API call (you can mock the API with setTimeout). Open the network tab in your browser's dev tools and verify that requests are only sent after you stop typing for the specified delay.

Next: State Management Basics & Data Flow

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Client-Server Interaction Fundamentals

Next

State Management Basics & Data Flow