Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

arthurvr
Copy link
Member

Would fix gh-679

@scottgonzalez
Copy link
Member

In my opinion, this is too strongly worded. There are many sane uses of these selectors that don't warrant a strong warning.

@dmethvin
Copy link
Member

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>&lt;img onload=""&gt;</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.
Copy link
Member

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"?

Copy link
Member Author

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.

@timmywil
Copy link
Member

How about "can have performance implications" instead of "has some performance implications"? I'm ok with the way it is, though.

@scottgonzalez
Copy link
Member

How about "can have performance implications"

+1

@arthurvr
Copy link
Member Author

👍. I updated the PR. Looking good now?

@scottgonzalez
Copy link
Member

"Using this selector heavily" sounds odd. Do you mean things like using this inside a loop?

@dmethvin
Copy link
Member

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.

@arthurvr
Copy link
Member Author

Any suggestions are welcome, though I think it's quite okay.

@dmethvin
Copy link
Member

I think it's good now. 👍

@arthurvr arthurvr closed this in e0fac2a Mar 30, 2015
@arthurvr arthurvr deleted the perf branch March 30, 2015 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Selectors :hidden/:visible are slow and can force layout
6 participants