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

Comments

Projects
None yet
3 participants
@SeanHenderson
Contributor

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 the Manipulation label Sep 1, 2015

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

@mgol

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol Sep 1, 2015

Member

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?

Member

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

This comment has been minimized.

Show comment
Hide comment
@SeanHenderson

SeanHenderson Sep 2, 2015

Contributor

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

Contributor

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

Manipulation: Switch rnoInnerhtml to a version more performant in IE
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 gh-2563
Closes gh-2568

SeanHenderson added a commit to SeanHenderson/jquery that referenced this issue Sep 3, 2015

Manipulation: Switch rnoInnerhtml to a version more performant in IE
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 gh-2563
Closes gh-2574

@mgol mgol closed this in d4def22 Sep 8, 2015

mgol added a commit that referenced this issue Sep 8, 2015

Manipulation: Switch rnoInnerhtml to a version more performant in IE
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 modified the milestones: 1.12/2.2, 3.0.0 Jan 8, 2016

@cssmagic cssmagic referenced this issue May 18, 2016

Open

jQuery #5

@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.