VHow do you keep a large frontend codebase from slowing down?
Sentido da resposta✓
Língua2
Pergunta do entrevistadorFrontend
Os entrevistadores de funções de frontend começam muitas vezes pela plataforma: como o navegador apresenta uma página, como o JavaScript lida com a espera e como o CSS constrói um layout. As frameworks mudam de poucos em poucos anos, mas estas ideias mantêm-se. Se as souber explicar em inglês simples, consegue trabalhar com qualquer framework.
Mantenha as respostas práticas. Diga o que mediria, o que verificaria nas ferramentas do navegador e o que o utilizador veria. Os entrevistadores gostam de candidatos que ligam os pormenores técnicos à experiência de uma pessoa real a usar a página.
- ✓Palavras → expressões → frases → fala
- ✓Sentido da resposta
- ✓Língua
Perguntas habituais e respostas de exemplo
How does the browser turn HTML and CSS into a visible page?
Como transforma o navegador o HTML e o CSS numa página visível?
O que o entrevistador quer ouvir. Os passos (DOM, estilos, layout, paint, compositing) e que alterações são caras.
Resposta de exemplo em inglês para praticar em voz altaThe 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?
Como funciona o código assíncrono em JavaScript?
O que o entrevistador quer ouvir. Uma única thread principal, o event loop, a diferença entre tarefas e callbacks de promises e a regra prática de nunca bloquear a thread.
Resposta de exemplo em inglês para praticar em voz altaJavaScript 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?
Como gere o estado numa aplicação de frontend?
O que o entrevistador quer ouvir. Diferentes tipos de estado (local, partilhado, do servidor, do URL) e o princípio de uma única fonte de verdade, sem nomear uma biblioteca em particular.
Resposta de exemplo em inglês para praticar em voz altaI 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?
Uma página carrega devagar. Como encontra a causa e a corrige?
O que o entrevistador quer ouvir. Um método que começa por medir, as Core Web Vitals como enquadramento e várias correções concretas, com uma verificação final.
Resposta de exemplo em inglês para praticar em voz altaI 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?
Como torna uma página web acessível?
O que o entrevistador quer ouvir. Primeiro HTML semântico, suporte de teclado, contraste e alternativas de texto, uso cuidadoso do ARIA e testes manuais.
Resposta de exemplo em inglês para praticar em voz altaAccessibility 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.
Como pronunciar os termos-chave
- JavaScript
- djá-va-skript
- DOM
- dí-ôu-ém (diga cada letra)
- asynchronous
- êi-sín-kra-nus
- accessibility
- ak-sé-si-bí-li-ti
- semantic
- si-mán-tik
- responsive
- ri-spón-siv
- viewport
- viú-port
Frases úteis para responder
- I would measure it first with the performance tools.Eu mediria primeiro com as ferramentas de desempenho.
- That change triggers a layout recalculation.Essa alteração desencadeia um recálculo do layout.
- The state should live as close as possible to where it is used.O estado deve ficar o mais perto possível de onde é usado.
- I would use a native element here, because it is accessible by default.Eu usaria aqui um elemento nativo, porque é acessível por predefinição.
- The main thread is blocked, so the page freezes.A thread principal está bloqueada, por isso a página bloqueia.
- It depends on whether the data is local or comes from the server.Depende de os dados serem locais ou virem do servidor.
- From the point of view of the user, what changes?Do ponto de vista do utilizador, o que muda?
Erros comuns a evitar
- Explicar apenas uma framework. Se disser "the framework updates the screen", diga também o que o navegador faz por baixo. Os entrevistadores testam primeiro os fundamentos.
- Dizer "Java" quando quer dizer "JavaScript". São linguagens diferentes e confundi-las soa a descuido. Diga djá-va-skript com clareza.
- Otimizar sem medir. Diga que ferramenta usaria e que número vigiaria antes e depois.
- Tratar a acessibilidade como um extra para o fim do projeto. Diga que a incorpora desde o início, com HTML semântico e testes de teclado.
- Usar adjetivos em vez de advérbios, como em «carrega lento» ou «funciona bom»: "the page loads slow" ou "it works good". Diga "the page loads slowly" e "it works well".
Perguntas frequentes
Que framework devo dizer que conheço?
Nomeie a que usou num projeto real e diga como a usou. Muitos entrevistadores preocupam-se mais com os fundamentos de HTML, CSS e JavaScript e depois verificam se os aplicou bem na framework.
Como explico o layout em CSS numa entrevista?
Diga que o Flexbox serve para layout a uma dimensão, uma linha ou uma coluna, e que o Grid serve para duas dimensões, linhas e colunas em conjunto. Os dois são muitas vezes usados na mesma página. Mencione o modelo de caixa e o design responsivo com media queries e dê um exemplo do seu trabalho.
Vou ter de programar ao vivo?
Muitas vezes, sim: um pequeno componente ou uma função com código assíncrono. Diga o seu plano em voz alta: primeiro a estrutura em HTML, depois os estilos e depois o comportamento. Mencione o estado vazio, o estado de carregamento e o teclado, porque mostram experiência.
Ler uma resposta não é o mesmo que dizê-la. Pratique cada pergunta em voz alta e depois compare o sentido e a língua da sua própria resposta.
Experimentar o SpeakRole ↗