Side navigation
#7156 closed enhancement (duplicate)
Opened October 12, 2010 02:46AM UTC
Closed April 17, 2011 12:52AM UTC
Last modified April 17, 2011 12:52AM UTC
html can be ~33% faster
| Reported by: | markg85 | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | manipulation | Version: | 1.4.2 |
| Keywords: | html | Cc: | |
| Blocked by: | Blocking: |
Description
Hi,
I was playing a bit with the jquery source (1.4.3 RC1) and found that the "html:" function can be ~33% faster simply by removing the "shortcut" option...
here is the code part that i have now and is a consistently faster from 37ms to 21ms:
html: function( value ) {
if ( value === undefined ) {
return this[0] && this[0].nodeType === 1 ?
this[0].innerHTML.replace(rinlinejQuery, "") :
null;
} else if ( jQuery.isFunction( value ) ) {
this.each(function(i){
var self = jQuery(this);
self.html( value.call(this, i, self.html()) );
});
} else {
this.empty().append( value );
}
return this;
},
Apparently something in the "shortcut" path was draining cycles?
Regards,
Mark
Attachments (0)
Change History (6)
Changed October 12, 2010 02:53AM UTC by comment:1
| keywords: | → html |
|---|---|
| type: | bug → enhancement |
Changed October 13, 2010 01:18AM UTC by comment:2
| component: | unfiled → manipulation |
|---|---|
| description: | Hi, \ \ I was playing a bit with the jquery source (1.4.3 RC1) and found that the "html:" function can be ~33% faster simply by removing the "shortcut" option... \ \ here is the code part that i have now and is a consistently faster from 37ms to 21ms: \ \ html: function( value ) { \ if ( value === undefined ) { \ return this[0] && this[0].nodeType === 1 ? \ this[0].innerHTML.replace(rinlinejQuery, "") : \ null; \ } else if ( jQuery.isFunction( value ) ) { \ this.each(function(i){ \ var self = jQuery(this); \ self.html( value.call(this, i, self.html()) ); \ }); \ \ } else { \ this.empty().append( value ); \ } \ \ return this; \ }, \ \ Apparently something in the "shortcut" path was draining cycles? \ \ Regards, \ Mark → Hi, \ \ I was playing a bit with the jquery source (1.4.3 RC1) and found that the "html:" function can be ~33% faster simply by removing the "shortcut" option... \ \ here is the code part that i have now and is a consistently faster from 37ms to 21ms: \ \ {{{ \ html: function( value ) { \ if ( value === undefined ) { \ return this[0] && this[0].nodeType === 1 ? \ this[0].innerHTML.replace(rinlinejQuery, "") : \ null; \ } else if ( jQuery.isFunction( value ) ) { \ this.each(function(i){ \ var self = jQuery(this); \ self.html( value.call(this, i, self.html()) ); \ }); \ \ } else { \ this.empty().append( value ); \ } \ \ return this; \ }, \ }}} \ \ Apparently something in the "shortcut" path was draining cycles? \ \ Regards, \ Mark |
| priority: | undecided → low |
| status: | new → open |
The more complex the HTML, the faster the “shortcut” method should be. How complex is the HTML that you are testing here?
Changed October 13, 2010 01:22AM UTC by comment:3
I actually tested this with the "taskspeed" benchmarking tool. I didn't add/change any text.. it's just that tool only with those lines removed.
Changed November 12, 2010 02:40AM UTC by comment:4
| milestone: | 1.4.3 |
|---|
Resetting milestone to future.
Changed April 17, 2011 12:52AM UTC by comment:5
| resolution: | → duplicate |
|---|---|
| status: | open → closed |
Two other people have suggested this idea quite recently but I'm currently trying to track down the tickets so we can reference them.
I'll see if I can find out why we're specifically using 'shortcut' in the above and follow up.
Moving to enhancements for now.