Skip to content

Conversation

@syranide
Copy link
Contributor

http://jsperf.com/escapeindexo/2 (short strings), http://jsperf.com/escapeindexo/3 (long strings)

Rough performance figures in IE8 and Chrome:
Testing and not escaping results in +100-200% (short), +30-70% (long)
Testing and escaping results in -33% (short and long)

Performance gained by this PR naturally increases for shorter strings and decrease for longer strings, considering that most of the attributes (style being the exception) generally have very short strings, this is good.

I would think that (far) more than half of the strings we pass through that function don't need to be escaped, meaning this should result in a performance improvement.

Also changed ESCAPE_LOOKUP to use single quotes while I was at it (feel free to object :)).
I'm not convinced that we should take it, posting this to share my results.

@syranide syranide changed the title escapeTextForBrowser, test string for unsafe chars before escaping [RFC] escapeTextForBrowser, test string for unsafe chars before escaping Sep 29, 2014
@syranide syranide changed the title [RFC] escapeTextForBrowser, test string for unsafe chars before escaping [idea] escapeTextForBrowser, test string for unsafe chars before escaping Sep 29, 2014
@sophiebits
Copy link
Collaborator

Going to close this, let's reopen if escapeTextForBrowser is actually a bottleneck.

@sophiebits sophiebits closed this May 6, 2015
@syranide syranide deleted the escapetest branch May 6, 2015 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants