Igglyboo
Igglyboo

Reputation: 845

HTML Color format performance

I plan to be changing the color of a few hundred thousand divs a second and was wondering what the fastest way to do it was.

What are the best formats in terms of performance? rgb triples? hex codes? color words(black, chartreuse)?

Upvotes: -1

Views: 103

Answers (2)

Joeytje50
Joeytje50

Reputation: 19112

I've run this jsPerf, and these are the general results:

  • basic color keywords is quite fast, and it's the fastest for Chrome. The extended list is a lot slower in some browsers though.
  • hsl is just the worst, except for IE, where it is actually the fasted (but then again, IE) (apparently this was just a single case, I couldn't reproduce it afterwards)
  • #RGB or #RRGGBB are both relatively fast in every browser (#RGB is slightly faster in general)
  • rgb() is generally slow, in every browser

In general, I think #RGB is the fastest format for every browser (on average).

Upvotes: 3

user3558826
user3558826

Reputation: 1

Hex codes would be the fastest. When you say for instance "black", it is read then changed to its hex code #000000

Upvotes: 0

Related Questions