VHow do you keep a large frontend codebase from slowing down?
Interviewer questionFrontend
Interviewers for frontend roles often start with the platform: how the browser renders a page, how JavaScript handles waiting, and how CSS builds a layout. Frameworks change every few years, but these ideas stay the same. If you can explain them in simple English, you can work with any framework.
Keep your answers practical. Say what you would measure, what you would check in the browser tools and what the user would see. Interviewers like candidates who connect technical details with the experience of a real person using the page.
- ✓Words → phrases → sentences → speaking
- ✓Answer meaning
- ✓Language
Common questions and sample answers
How does the browser turn HTML and CSS into a visible page?
What the interviewer wants to hear. The steps (DOM, styles, layout, paint, compositing), and which changes are expensive.
Sample answer to practise aloudThe browser parses the HTML into the DOM and the CSS into a style model. It combines them to find out what is visible and which styles apply. Then it does layout, which calculates the size and position of every element, then paint, which draws the pixels, and finally compositing, which puts the layers together. Layout is the expensive part. If I change something that affects geometry, like width or position, the browser may recalculate the layout for many elements. Changes to transform and opacity are usually cheaper, because the browser can often handle them in the compositing step. Also, scripts in the head can block rendering, so I load non-critical ones with defer or async.
How does asynchronous code work in JavaScript?
What the interviewer wants to hear. One main thread, the event loop, the difference between tasks and promise callbacks, and the practical rule of never blocking the thread.
Sample answer to practise aloudJavaScript runs on one main thread, so it does one thing at a time. When I start something slow, like a network request, the browser does the waiting outside the main thread. When the work finishes, a callback goes into a queue. The event loop takes work from the queue when the call stack is empty. Promise callbacks use a separate microtask queue, which runs before the next regular task. The async and await syntax sits on top of promises and makes asynchronous code look sequential. The practical rule is to never block the main thread with a long loop, because the page freezes. I also always handle errors, with try and catch or with a catch on the promise.
How do you manage state in a frontend application?
What the interviewer wants to hear. Different kinds of state (local, shared, server, URL) and the principle of one source of truth, without naming a specific library.
Sample answer to practise aloudI separate state by type. Local state, like whether a dropdown is open, stays inside the component. Shared client state, like the current user or a shopping cart, may need a central store or a shared context. Server state, like a list loaded from an API, is different. It needs caching, loading and error handling, and refetching, so I use a data-fetching layer for it and do not copy it into a global store. The URL is also state: filters and page numbers belong there, so users can share links. My rule is to keep state close to where it is used, and to have one source of truth for every piece of data.
A page loads slowly. How do you find the cause and fix it?
What the interviewer wants to hear. A measurement-first method, Core Web Vitals as a frame, and several concrete fixes, with a final check.
Sample answer to practise aloudI start by measuring, not guessing. I use the performance tools of the browser to see the loading time, and field data if I have it. The Core Web Vitals give a good frame: how fast the main content appears, how quickly the page responds to input, and whether the layout jumps. Common fixes are sending less JavaScript by splitting the bundle, compressing and resizing images, loading things below the fold lazily, caching static files with a CDN, and reserving space for images to avoid layout shifts. After each change, I measure again, because an optimisation that I cannot measure may not help.
How do you make a web page accessible?
What the interviewer wants to hear. Semantic HTML first, keyboard support, contrast and text alternatives, careful use of ARIA, and manual testing.
Sample answer to practise aloudAccessibility means that people can use the page with a keyboard, a screen reader or other assistive technology, and with different abilities. I start with semantic HTML: a real button for actions, a link for navigation, proper headings and labels for form fields. Native elements give keyboard support and the right role for free. I check that everything works with the keyboard alone, with a visible focus. I keep enough colour contrast and I write a meaningful alt text for images. I use ARIA only when native HTML is not enough, because wrong ARIA is worse than none. I test with automated tools and also by hand, because tools find only part of the problems.
How to say the key terms
- JavaScript
- JAH-vuh-skript
- DOM
- D-O-M (say each letter)
- asynchronous
- ay-SIN-kruh-nus
- accessibility
- ak-ses-ih-BIL-ih-tee
- semantic
- sih-MAN-tik
- responsive
- rih-SPON-siv
- viewport
- VYOO-port
Useful phrases for answering
- I would measure it first with the performance tools.
- That change triggers a layout recalculation.
- The state should live as close as possible to where it is used.
- I would use a native element here, because it is accessible by default.
- The main thread is blocked, so the page freezes.
- It depends on whether the data is local or comes from the server.
- From the point of view of the user, what changes?
Common mistakes to avoid
- Explaining only a framework. If you say "the framework updates the screen", also say what the browser does underneath. Interviewers test the fundamentals first.
- Saying "Java" when you mean "JavaScript". They are different languages, and mixing them up sounds careless. Say JAH-vuh-skript clearly.
- Optimising without measuring. Say which tool you would use and which number you would watch before and after.
- Treating accessibility as an extra for the end of the project. Say that you build it in from the start, with semantic HTML and keyboard testing.
- Using adjectives instead of adverbs: "the page loads slow" or "it works good". Say "the page loads slowly" and "it works well".
Frequently asked questions
Which framework should I say that I know?
Name the one you used in a real project, and say how you used it. Many interviewers care more about the fundamentals of HTML, CSS and JavaScript, and then check whether you applied them well in the framework.
How do I explain CSS layout in an interview?
Say that Flexbox is for one-dimensional layout, a row or a column, and Grid is for two dimensions, rows and columns together. Both are often used on the same page. Mention the box model and responsive design with media queries, and give one example from your work.
Will I have to code live?
Often, yes: a small component, or a function with asynchronous code. Say your plan aloud: first the structure in HTML, then the styles, then the behaviour. Mention the empty state, the loading state and the keyboard, because these show experience.
Reading an answer is not the same as saying it. Practise each question out loud, then compare the meaning and the language of your own answer.
Try SpeakRole ↗Other topics in this area