Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!