Performance differences between color declarations?

前端 未结 6 1533
死守一世寂寞
死守一世寂寞 2020-12-08 14:49

In CSS we can use several different methods to define a color:

  • Color word: red
  • Hexadecimal: #FF0000
  • Red/Green/Blue
6条回答
  •  我在风中等你
    2020-12-08 15:37

    Edit: Each process has to get down to a binary value for r, g, and b. Hex and rgb bytes are already set up for that, so I guess they might actually be roughly the same speed. The rest have to go through a process to reach a hex/rgb value

    #FF0000 = memory values of: 1111 1111 0000 0000 0000 0000
    
    rgb(255,0,0) = memory values of: 1111 1111 0000 0000 0000 0000
    

    Both cases are most likely stored in 3 int variables. So the real question is, which is faster to process into binary values for these integers? HEX or DEC? I think HEX, but I can't back that up. Anyhow, the code just takes the binary values of these variables.

提交回复
热议问题