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

html() uses a regular expression that performs badly in IE > 9 #2563

Closed
SeanHenderson opened this issue Sep 1, 2015 · 2 comments
Closed

html() uses a regular expression that performs badly in IE > 9 #2563

SeanHenderson opened this issue Sep 1, 2015 · 2 comments

Comments

@SeanHenderson
Copy link
Contributor

@SeanHenderson SeanHenderson commented Sep 1, 2015

rnoInnerhtml = /<(?:script|style|link)/i

The above causes significant performance issues in IE 10 IE 11 and EDGE when inserting large amounts of HTML using the html function.

It can be re-written as the following:
rnoInnerhtml = /<script|<style|<link/i,

The above performs at the same level in other browsers and exponentially faster in IE .
My tests show for two columns for 4096 rows the difference is 18 seconds versus 5 milliseconds (IE 11).

http://jsfiddle.net/Lwa0t5rp/3/

Note when testing you the first test will always be slower than the second in chrome / firefox

Ticket logged at Microsoft however i think jQuery should be fixed anyways.
https://connect.microsoft.com/IE/feedback/details/1736512/regular-expressions-are-slower-in-edge-than-in-ie8

@mgol mgol added this to the 3.0.0 milestone Sep 1, 2015
@mgol
Copy link
Member

@mgol mgol commented Sep 1, 2015

Thanks for the report! I confirmed this is very slow in Edge (build 10240). Would you like to submit a PR to take the credit for the perf fix?

@SeanHenderson
Copy link
Contributor Author

@SeanHenderson SeanHenderson commented Sep 2, 2015

#2568 Not sure if this is done correctly / if this should also go in other branches as well

SeanHenderson added a commit to SeanHenderson/jquery that referenced this issue Sep 3, 2015
IE versions greater than 9 do not handle the old regular expression well with large html content
This is due to the use of a non-capturing group after a very common html character (<).

Test suite: http://jsfiddle.net/Lwa0t5rp/3/
Microsoft bug: https://connect.microsoft.com/IE/feedback/details/1736512/regular-expressions-are-slower-in-edge-than-in-ie8

Fixes jquerygh-2563
Closes jquerygh-2568
SeanHenderson added a commit to SeanHenderson/jquery that referenced this issue Sep 3, 2015
IE versions greater than 9 do not handle the old regular expression well with large html content
This is due to the use of a non-capturing group after a very common html character (<).

Test suite: http://jsfiddle.net/Lwa0t5rp/3/
Microsoft bug: https://connect.microsoft.com/IE/feedback/details/1736512/regular-expressions-are-slower-in-edge-than-in-ie8

Fixes jquerygh-2563
Closes jquerygh-2574
@mgol mgol closed this in d4def22 Sep 8, 2015
mgol added a commit that referenced this issue Sep 8, 2015
IE versions greater than 9 do not handle the old regular expression well
with large html content. This is due to the use of a non-capturing group
after a very common html character (<).

Test suite: http://jsfiddle.net/Lwa0t5rp/3/
Microsoft bug: https://connect.microsoft.com/IE/feedback/details/1736512/

(cherry-picked from d4def22)

Fixes gh-2563
Closes gh-2574
@dmethvin dmethvin added this to the 1.12/2.2 milestone Jan 8, 2016
@dmethvin dmethvin removed this from the 3.0.0 milestone Jan 8, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants