Skip to content

FYI: Regenerate entire style instead of diffing #1886

@syranide

Description

@syranide

@zpao brought up the idea of using cssText instead of diffing styles the other day... I didn't think it would be a good idea. I was apparently very much wrong because the cost of cssText seems to very identically to all other properties, so for 1 style, it's the same, but for 4 styles it really takes off. Performance also seems consistent across all browsers.

I messed up the test... buuuuuut, there is a significant benefit with no persistent styles, it's even more emphasized for the slower browsers. The thing that sticks out the most for me is that cssText is a lot more uniform in performance, whereas using properties is significantly worse in worst-case. However, with 4 persistent styles in-place, cssText loses big-time.

So it seems that it very much depends, if we want to suck every last piece of performance out and we could implement a fast routine (good thresholds are probably the biggest issue) that could intelligently use cssText or properties there could be quite a big win here though (for real). But I don't think have 2 different paths is a good thing, and this would only be applicable in certain cases (but perhaps rather common still).

http://jsperf.com/faststyle (4 persistent styles)
http://jsperf.com/faststyle/2 (no persistent styles)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions