Edward
Edward

Reputation: 4918

Will css position method affect browser rendering performance?

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? Compare to the case of no CSS.

Upvotes: 1

Views: 384

Answers (4)

Marco Demaio
Marco Demaio

Reputation: 34427

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.

Upvotes: 1

Dan Inactive
Dan Inactive

Reputation: 10060

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.

Upvotes: 1

Kyle
Kyle

Reputation: 67234

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.

Upvotes: 1

Tim
Tim

Reputation: 7056

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.

Upvotes: 1

Related Questions