Bug Tracker

Modify

Ticket #7156 (closed enhancement: duplicate)

Opened 3 years ago

Last modified 2 years ago

html can be ~33% faster

Reported by: markg85 Owned by:
Priority: low Milestone:
Component: manipulation Version: 1.4.2
Keywords: html Cc:
Blocking: Blocked by:

Description (last modified by snover) (diff)

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

comment:1 Changed 3 years ago by addyosmani

  • Keywords html added
  • Type changed from bug to enhancement

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 3 years ago by snover

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to manipulation
  • Description modified (diff)

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 3 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 3 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:5 Changed 2 years ago by john

  • Status changed from open to closed
  • Resolution set to duplicate

comment:6 Changed 2 years ago by john

Duplicate of #6782.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.