Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
Why is changing "transform" property on DOM element slow in Chrome?

My understanding is that changing the transform property on DOM elements should be fast, since it won't force layout or repainting. But things seem a bit sluggish, and profiling points towards changing transform as the culprit.

I have this code which updates the DOM element of a particle per its properties:

const applyCSSToParticle = (particle) => {
  const { elem, x, y, z, rot } = particle

  elem.style.transform =
    'translateX(' +
    x +
    'px) translateY(' +
    y +
    'px) rotate(' +
    rot +
    'deg) scale(' +
    z +
    ')'
}

And it's called by this function:

const applyPhysics = () => {
  requestAnimationFrame(applyPhysics)
  particles.forEach((particle, i) => {
    const { id, elem, text, x, y, z, xVel, yVel, zVel, rot, rVel } = particle

    particle.x += xVel * z
    particle.y += yVel * z
    particle.z = Math.min(z + zVel, maxZ)
    particle.rot += rVel
    applyCSSToParticle(particle)
  })

When I profile my code, I'm seeing that about 30% of the time is spent in applyCSSToParticle(). Any ideas on how to speed this up?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda