Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7156 closed enhancement (duplicate)

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 (last modified by snover)

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

Change History (6)

comment:1 Changed 9 years ago by addyosmani

Keywords: html added
Type: bugenhancement

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.

comment:2 Changed 9 years ago by snover

Component: unfiledmanipulation
Description: modified (diff)
Priority: undecidedlow
Status: newopen

The more complex the HTML, the faster the “shortcut” method should be. How complex is the HTML that you are testing here?

comment:3 Changed 9 years ago by markg85

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.

comment:4 Changed 9 years ago by snover

Milestone: 1.4.3

Resetting milestone to future.

comment:5 Changed 9 years ago by john

Resolution: duplicate
Status: openclosed

comment:6 Changed 9 years ago by john

Duplicate of #6782.

Note: See TracTickets for help on using tickets.