VHow do you keep a large frontend codebase from slowing down?
Питання інтерв’юераFrontend
Інтерв’юери на frontend-ролі часто починають із платформи: як браузер відображає сторінку, як JavaScript обробляє очікування і як CSS будує розмітку. Фреймворки змінюються кожні кілька років, а ці ідеї лишаються. Якщо ви вмієте пояснити їх простою англійською, ви впораєтеся з будь-яким фреймворком.
Робіть відповіді практичними. Скажіть, що ви виміряли б, що перевірили б в інструментах браузера і що побачив би користувач. Інтерв’юерам подобаються кандидати, які пов’язують технічні деталі з досвідом реальної людини, що користується сторінкою.
- ✓Слова → фрази → речення → мовлення
- ✓Зміст відповіді
- ✓Мова
Поширені запитання та зразки відповідей
How does the browser turn HTML and CSS into a visible page?
Як браузер перетворює HTML і CSS на видиму сторінку?
Що хоче почути інтерв’юер. Кроки (DOM, стилі, layout, paint, compositing) і які зміни дорогі.
Зразок відповіді англійською для тренування вголосThe 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?
Як працює асинхронний код у JavaScript?
Що хоче почути інтерв’юер. Один головний потік, цикл подій (event loop), різниця між завданнями й колбеками промісів і практичне правило ніколи не блокувати потік.
Зразок відповіді англійською для тренування вголосJavaScript 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?
Як ви керуєте станом у frontend-застосунку?
Що хоче почути інтерв’юер. Різні види стану (локальний, спільний, серверний, в URL) і принцип єдиного джерела істини без назви конкретної бібліотеки.
Зразок відповіді англійською для тренування вголосI 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?
Сторінка завантажується повільно. Як ви знаходите причину та виправляєте?
Що хоче почути інтерв’юер. Метод, що починається з вимірювання, Core Web Vitals як рамка та кілька конкретних виправлень із підсумковою перевіркою.
Зразок відповіді англійською для тренування вголосI 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?
Як ви робите веб-сторінку доступною (accessible)?
Що хоче почути інтерв’юер. Спершу семантичний HTML, підтримка клавіатури, контраст і текстові альтернативи, обережне користування ARIA та ручне тестування.
Зразок відповіді англійською для тренування вголосAccessibility 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.
Як вимовляти ключові терміни
- JavaScript
- джа́васкрипт
- DOM
- ді-оу-ем (кожну літеру окремо)
- asynchronous
- ейси́нкренес
- accessibility
- аксесибі́літі
- semantic
- семе́нтік
- responsive
- ріспо́нсів
- viewport
- в’ю́порт
Корисні фрази для відповіді
- I would measure it first with the performance tools.Спершу я б виміряв це в інструментах продуктивності.
- That change triggers a layout recalculation.Ця зміна запускає перерахунок розмітки (layout).
- 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?З погляду користувача, що змінюється?
Типові помилки
- Пояснювати лише фреймворк. Якщо ви кажете "the framework updates the screen", скажіть і те, що робить браузер під ним. Інтерв’юери спершу перевіряють основи.
- Казати "Java", коли маєте на увазі "JavaScript". Це різні мови, і плутанина звучить недбало. Чітко вимовляйте JAH-vuh-skript («джа́васкрипт»).
- Оптимізувати без вимірювання. Скажіть, яким інструментом ви б скористалися і за яким числом стежили б до та після.
- Вважати доступність додатком наприкінці проєкту. Скажіть, що закладаєте її з самого початку: семантичний HTML і тестування з клавіатури.
- Вживати прикметник замість прислівника, бо українське «повільно» чи «добре» не має окремої форми: "the page loads slow" чи "it works good". Кажіть "the page loads slowly" і "it works well".
Часті запитання
Який фреймворк краще назвати?
Назвіть той, яким користувалися в реальному проєкті, і скажіть, як саме. Багато інтерв’юерів більше дбають про основи HTML, CSS і JavaScript, а потім перевіряють, чи вдало ви застосували їх у фреймворку.
Як пояснити CSS-розмітку на співбесіді?
Скажіть, що Flexbox призначений для одновимірної розмітки, у рядок чи в стовпець, а Grid — для двовимірної, рядки й стовпці разом. Обидва часто використовують на одній сторінці. Згадайте блокову модель (box model) і адаптивний дизайн з media queries та наведіть один приклад зі своєї роботи.
Чи доведеться писати код наживо?
Часто так: невеликий компонент чи функцію з асинхронним кодом. Скажіть свій план уголос: спочатку структура в HTML, потім стилі, потім поведінка. Згадайте порожній стан, стан завантаження та клавіатуру, бо це показує досвід.
Прочитати відповідь — не те саме, що промовити її. Потренуйте кожне запитання вголос, а потім порівняйте зміст і мову власної відповіді.
Спробувати SpeakRole ↗Інші теми в цьому напрямі