开发者

Will css position method affect browser rendering performance?

开发者 https://www.devze.com 2022-12-29 15:13 出处:网络
Considerring two DIVs A and B, which A includes B, and CSS: A { margin-left: -2000px; } B { margin-left: 2000px; }

Considerring two DIVs A and B, which A includes B, and CSS:

A { margin-left: -2000px; }
B { margin-left: 2000px; }

with this CSS, position of B is no difference to its situation with no CSS, i want to know will there be a performance decrease when rendering? Compa开发者_Python百科re to the case of no CSS.


You are making the browser do uneccesary CSS calculation, so it will be a really tiny infinitesimal bit less performant. :)

No user will probably ever notice it!

To do a similarity with coding a processor take less when declaring a variable in this way:

var a = 0;

rather than doing:

var a = 1 - 1;

but I believe nobody (from a user stand point) will ever feel the difference except coders that would think at you as a wired personality when they read in your code such kind of stuff.


Not really. If there was, you would be talking 0.01 of a seconds' worth.

If you applied conflicting settings to the same element, the last setting will be used.


Considering the speed of most connections, you've probably not got much to worry about. Unless you're using a Stylesheet that has thousands of lines, might be good to put it through a Compression tool, but other than that, I wouldn't worry too much about it.


The only situation when I noticed a performance decrease is with elements that have position:fixed (they stick to the same position while you scroll)... Firefox becomes (ever so slightly) choppy when you scroll the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号