Bug Tracker

Opened 10 years ago

Closed 10 years ago

#9334 closed enhancement (patchwelcome)

Some ideas on reducing the file size

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: 1.next
Component: misc Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:


I am not sure whether these are reasonable improvements or whether they have possible side effects, but I would like to shed some light on them:

  • Use [] instead of Array.prototype. [].slice is used at certain places, but Array.prototype.push at other places.
  • Use ({}) instead of Object.prototype
  • The trim function could be smallened to one function like this:
trim: function( text ) {
        return text == null ?
            "" :
            String.trim ?
                String.trim.call( text ) :
                text.toString().replace( trimLeft, "" ).replace( trimRight, "" );

Change History (4)

comment:1 Changed 10 years ago by anonymous

I meant [].splice instead of [].slice, I'm sorry.

comment:2 Changed 10 years ago by addyosmani

Component: unfiledmisc
Owner: set to anonymous
Priority: undecidedlow
Status: newpending

Thanks for submitting a ticket to the jQuery Project!. I'm skeptical about the benefits of us replacing Array.prototype/Object.prototype etc with these shorthands. Do you have a fork of jQuery somewhere where these have been replaced and proven to actually work/pass our tests without anything breaking?. If not we may end up closing this ticket until there's further evidence. Leaving open now for further review.

comment:3 Changed 10 years ago by anonymous

Status: pendingnew

I'm sorry but I have not yet been able to get git working. If the ideas are not really improving then please just ignore them.

comment:4 Changed 10 years ago by dmethvin

Resolution: patchwelcome
Status: newclosed

These are definitely changes that need to be tested for benefit. Usually we have something like var slice = Array.prototype.slice at the top of a file if we're using it more than once, to save space. [].prototype.slice is a bit smaller but it does create an object just to get the method.

Since the ticket doesn't report a specific problem I'll close it.

Note: See TracTickets for help on using tickets.