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

Avoid Recalculation of style #3

Closed
NiciusB opened this issue Sep 24, 2018 · 1 comment
Closed

Avoid Recalculation of style #3

NiciusB opened this issue Sep 24, 2018 · 1 comment
Assignees
Labels
Projects

Comments

@NiciusB
Copy link

NiciusB commented Sep 24, 2018

Right now, every mouse click or keyboard press is changing the content of the style tag, forcing the browser to recalculate the style:
image

You can avoid changing the content of style_element on set_css if the new content is the same as the current one.
Since I don't need support for IE, I have used the following:

set_css = function(css_text){
    if (css_text !== style_element.innerHTML) style_element.innerHTML = css_text;
}

However, the code can be changed to allow support for IE by checking the other method as well, or maybe keeping a boolean variable inside the anonymous function

@lindsayevans lindsayevans self-assigned this Sep 27, 2018
@lindsayevans
Copy link
Owner

Thanks @NiciusB - I'll look at fixing this in v2

@lindsayevans lindsayevans added this to To do in v2 via automation Sep 27, 2018
lindsayevans added a commit that referenced this issue Sep 28, 2018
* Only determine cssText support on init
* Check if css has changed before setting it
@lindsayevans lindsayevans moved this from To do to Done in v2 Sep 28, 2018
@NiciusB NiciusB closed this as completed Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
v2
  
Done
Development

No branches or pull requests

2 participants