Skip to content

Performance of setStyle #2679

@oallouch

Description

@oallouch

Hi everyone,
In modern web (or mobile) applications, setStyle can be called millions of times. It's, for me, the most crucial code for good lower level performance.
So, optimization ideas for the Element.setStyle function:
. remove the camelCase(). I've already done it in my version. Try it ! It's great :)
. remove the Math.round around 'val'. With retina screens, sub-pixels become real pixels
. (Element.Styles[property] || '@').split(' ') should be cached. Instead of Strings, Element.Styles values should be Arrays
. if the split array has a length of 1, we don't have to do a "Array.from(value)"

What do you think of it ?

Thx,

Olivier Allouch
http://www.illicotravel.com

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6506644-performance-of-setstyle?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions