Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate whether style setting can be more optimized #929

Closed
sophiebits opened this issue Jan 17, 2014 · 3 comments
Closed

Investigate whether style setting can be more optimized #929

sophiebits opened this issue Jan 17, 2014 · 3 comments

Comments

@sophiebits
Copy link
Collaborator

See http://jsfiddle.net/Ut2X6/; if you do a profile, setValueForStyles takes most of the time.

@sophiebits
Copy link
Collaborator Author

Perhaps relevant: http://jsperf.com/style-vs-csstext-vs-setattribute/8. Not sure if I screwed something up there because when running the first snippet the boxes don't seem to appear but for the other three they do.

@SanderSpies
Copy link
Contributor

Would also look into using

var styleNames = Object.keys(styles);
for (var i = 0, l = styleNames.length; i < l; i++) {
var styleName = styleNames[i];

instead of:

for (var styleName in styles) {
if (!styles.hasOwnProperty(styleName)) {
continue;
}

@sophiebits
Copy link
Collaborator Author

Replacing setValueForStyles with

  setValueForStyles: function(node, styles) {
    node.style.top = styles.top + 'px';
    node.style.left = styles.left + 'px';
    node.style.background = styles.background;
  }

doesn't give a noticeable bump on that benchmark (possibly 5%, but hard to tell), so it's hard for me to believe there's much we can do here. Closing…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants