Skip to main content

Bug Tracker

Side navigation

#6782 closed enhancement (fixed)

Opened July 11, 2010 04:23AM UTC

Closed September 22, 2011 03:22AM UTC

Last modified March 08, 2012 11:38PM UTC

carefully allow more strings to use innerHTML

Reported by: cmcnulty Owned by: dmethvin
Priority: blocker Milestone: 1.7
Component: manipulation Version: 1.4.4
Keywords: html,1.7-discuss Cc:
Blocked by: Blocking:
Description

.html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string.

I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense.

The new regex only excludes <style and <script for the following documented reasons:

style:

http://dev.jquery.com/ticket/5977

script:

http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/

<object and <embed

Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5.

I discussed these changes a while back in this topic:

http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382

Attachments (2)
Change History (25)

Changed November 12, 2010 02:40AM UTC by snover comment:1

milestone: 1.4.3

Resetting milestone to future.

Changed November 21, 2010 04:23AM UTC by snover comment:2

milestone: → 1.5
priority: → high
status: newopen
version: 1.4.21.4.4

Changed February 24, 2011 11:24PM UTC by cmcnulty comment:3

Created a jsperf test to show the performance increase:

http://jsperf.com/tweaks-to-rnocache

I extend jquery to create a .html2() which is identical to .html() except that rather than using nocache it uses a regex test that it optimized for .html()

Changed March 10, 2011 07:44PM UTC by cmcnulty comment:4

Changed April 17, 2011 12:50AM UTC by john comment:5

milestone: → 1.next

Changed April 17, 2011 12:52AM UTC by john comment:6

#7156 is a duplicate of this ticket.

Changed April 17, 2011 05:41AM UTC by john comment:7

#7338 is a duplicate of this ticket.

Changed April 18, 2011 01:48AM UTC by wookiehangover comment:8

owner: → wookiehangover
status: openassigned

I'm gonna take crack at this.

Changed April 19, 2011 02:15PM UTC by cmcnulty comment:9

Glad to hear this has been assigned. I've been pushing for this change for a long time and am very familiar with at least some of the issues involved. Feel free to let me know if you have any questions! I'm not convinced that this little change is going to be a cure-all for the #7341 problems, but it should help a bit in IE 7,8,9.

Changed May 22, 2011 07:27PM UTC by john comment:10

keywords: htmlhtml,1.7-discuss

Nominating ticket for 1.7 discussion.

Changed May 23, 2011 12:04AM UTC by jaubourg comment:11

description: .html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense. \ \ The new regex only excludes <style and <script for the following documented reasons: \ \ style: \ http://dev.jquery.com/ticket/5977 \ \ script: \ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/ \ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5. \ \ I discussed these changes a while back in this topic: \ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382.html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense.\ \ The new regex only excludes <style and <script for the following documented reasons:\ \ style:\ http://dev.jquery.com/ticket/5977\ \ script:\ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/\ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5.\ \ I discussed these changes a while back in this topic:\ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382

+0, What about IE6? Need proof.

Changed May 23, 2011 02:10AM UTC by ajpiano comment:12

description: .html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense.\ \ The new regex only excludes <style and <script for the following documented reasons:\ \ style:\ http://dev.jquery.com/ticket/5977\ \ script:\ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/\ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5.\ \ I discussed these changes a while back in this topic:\ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382.html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense. \ \ The new regex only excludes <style and <script for the following documented reasons: \ \ style: \ http://dev.jquery.com/ticket/5977 \ \ script: \ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/ \ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5. \ \ I discussed these changes a while back in this topic: \ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382

+1, If the perf here is demonstrable in IE, then let's go for it.

Changed May 23, 2011 03:22AM UTC by timmywil comment:13

description: .html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense. \ \ The new regex only excludes <style and <script for the following documented reasons: \ \ style: \ http://dev.jquery.com/ticket/5977 \ \ script: \ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/ \ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5. \ \ I discussed these changes a while back in this topic: \ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382.html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense.\ \ The new regex only excludes <style and <script for the following documented reasons:\ \ style:\ http://dev.jquery.com/ticket/5977\ \ script:\ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/\ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5.\ \ I discussed these changes a while back in this topic:\ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382

+1, I'm all for perf improvements.

Changed May 23, 2011 02:58PM UTC by cmcnulty comment:14

Replying to [comment:11 jaubourg]:

+0, What about IE6? Need proof.

IE6 sees near 100% performance increase, passes all unit tests.

Changed May 23, 2011 03:18PM UTC by rwaldron comment:15

description: .html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense.\ \ The new regex only excludes <style and <script for the following documented reasons:\ \ style:\ http://dev.jquery.com/ticket/5977\ \ script:\ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/\ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5.\ \ I discussed these changes a while back in this topic:\ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382.html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense. \ \ The new regex only excludes <style and <script for the following documented reasons: \ \ style: \ http://dev.jquery.com/ticket/5977 \ \ script: \ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/ \ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5. \ \ I discussed these changes a while back in this topic: \ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382

@cmcnulty can you provide a test case that we can view in IE6?

Changed May 23, 2011 03:35PM UTC by cmcnulty comment:16

Replying to [comment:15 rwaldron]:

@cmcnulty can you provide a test case that we can view in IE6?

I'd be happy to, but I'm not sure exactly what you're looking for. I've tested the change in jsperf with IE6, and the pull request passes all of the unit tests. The nice thing about this change is that existing unit tests already cover pretty much this entire change ''except'' for <EMBED which is the only thing the pull request adds a unit test for. (None currently exist for EMBED anywhere in the unit tests) Other than that, there are already tests in place for, for instance, making sure that an option stays selected, making sure the <OBJECT is inserted properly, etc.

Changed May 23, 2011 09:41PM UTC by dmethvin comment:17

+1

Changed June 03, 2011 01:33PM UTC by john comment:18

description: .html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense. \ \ The new regex only excludes <style and <script for the following documented reasons: \ \ style: \ http://dev.jquery.com/ticket/5977 \ \ script: \ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/ \ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5. \ \ I discussed these changes a while back in this topic: \ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382.html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense.\ \ The new regex only excludes <style and <script for the following documented reasons:\ \ style:\ http://dev.jquery.com/ticket/5977\ \ script:\ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/\ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5.\ \ I discussed these changes a while back in this topic:\ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382

+1, If we think that this might work as we expect it to, then let's go for it.

Changed June 03, 2011 02:48PM UTC by scottgonzalez comment:19

+1

Changed June 04, 2011 10:18PM UTC by addyosmani comment:20

+1

Changed June 05, 2011 09:15PM UTC by rwaldron comment:21

+1

Changed June 06, 2011 03:50PM UTC by jzaefferer comment:22

+0

Changed July 12, 2011 03:14PM UTC by dmethvin comment:23

description: .html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense.\ \ The new regex only excludes <style and <script for the following documented reasons:\ \ style:\ http://dev.jquery.com/ticket/5977\ \ script:\ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/\ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5.\ \ I discussed these changes a while back in this topic:\ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382.html() uses rnocache to determine both if a snippet should be cached by buildFragment() and also whether or not html() should use append or innerHTMLto insert the snippet. The problem is that buildFragment requires more stringent rules than innerHTML does, and therefore fewer strings use innerHTML than otherwise could, and that hurts performance, particularly by stripping all snippets with an <option anywhere in the string. \ \ I therefore suggest a new regex rule explicitly to determine if innerHTML or append method should be used. Not only will the improve performance, but it also makes the code cleaner, more readable and make more sense. \ \ The new regex only excludes <style and <script for the following documented reasons: \ \ style: \ http://dev.jquery.com/ticket/5977 \ \ script: \ http://poeticcode.wordpress.com/2007/10/03/innerhtml-and-script-tags/ \ \ <object and <embed \ \ Have tests added to them, and cause no new failures in IE7, FF3.7 or Chrome 5. \ \ I discussed these changes a while back in this topic: \ \ http://forum.jquery.com/topic/html-performance-vs-cruft#14737000000784382
milestone: 1.next1.7
priority: highblocker

Changed July 25, 2011 04:15PM UTC by john comment:24

owner: wookiehangoverdmethvin

Changed September 22, 2011 03:22AM UTC by dmethvin comment:25

resolution: → fixed
status: assignedclosed