Hacker News new | ask | show | jobs
by throwaway0asd 1355 days ago
QuerySelectors are slow. Epic slow. I would also argue that querySelectors are far less flexible and became popular because they are instead easy.

https://jsbench.github.io/#b39045cacae8d8c4a3ec044e538533dc

ProTip: Without numbers performance opinions are wrong by several orders of magnitude 80% of the time.

1 comments

I’m getting 70mops byId and 23mops qs-#id. This looks like making a huge difference until I add these cases:

  3: "abc”.replace("a", "b")
  4: "1" * 2
Which result in 15mops and 74mops respectively. This test measures diameters of neutrinos so to say.
My experience is that most developers tend to guess at performance and throw away numbers they disagree with. As a result performance testing is only something product owners care about.