DEV Community

Discussion on: Generate and Set Pseudorandom Hexadecimal Background Color Using JavaScript

Collapse
 
antjanus profile image
Antonin J. (they/them)

I saw a tweet about this last week! Using document.querySelector('body') is actually more performant than using document.body. So I wonder if doing document.querySelector('#some-id') would still be faster than document.body! :)

Thread Thread
 
somedood profile image
Basti Ortiz

I wonder if there's a jsPerf for that by now. I'm really curious to see which method is more performant.