-
Notifications
You must be signed in to change notification settings - Fork 263
hidden/visible-selector: add note about performance #682
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
Conversation
In my opinion, this is too strongly worded. There are many sane uses of these selectors that don't warrant a strong warning. |
It's actually pretty weasel worded as it is. What alternate wording would you suggest? |
@@ -58,6 +58,9 @@ | |||
<xsl:when test="@id = 'html-code-execution'"> | |||
By design, any jQuery constructor or method that accepts an HTML string — <a href="/jQuery/">jQuery()</a>, <a href="/append/">.append()</a>, <a href="/after/">.after()</a>, etc. — can potentially execute code. This can occur by injection of script tags or use of HTML attributes that execute code (for example, <code><img onload=""></code>). Do not use these methods to insert strings obtained from untrusted sources such as URL query parameters, cookies, or form inputs. Doing so can introduce cross-site-scripting (XSS) vulnerabilities. Remove or escape any user input before adding content to the document. | |||
</xsl:when> | |||
<xsl:when test="@id = 'hidden-forces-layout'"> | |||
Using this selector heavily has some performance regressions, as it may force the browser to re-render the page before it can determine visibility. Tracking the visibility of elements via other methods, for example using a class, can provide better performance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure "regressions" is the right word here. What is it regressing from? Maybe, especially considering @scottgonzalez's concerns, we could change it to "implications"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kswedberg Yup. Will update it.
How about "can have performance implications" instead of "has some performance implications"? I'm ok with the way it is, though. |
+1 |
👍. I updated the PR. Looking good now? |
"Using this selector heavily" sounds odd. Do you mean things like using this inside a loop? |
It could be inside a loop where the DOM is being changed and thus forcing recalc each time, or could be just used once or twice in a very large DOM. |
Any suggestions are welcome, though I think it's quite okay. |
I think it's good now. 👍 |
Would fix gh-679