Skip to main content

Bug Tracker

Side navigation

#9334 closed enhancement (patchwelcome)

Opened May 18, 2011 04:03PM UTC

Closed May 20, 2011 03:15PM UTC

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:
Description

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, "" );
       }
Attachments (0)
Change History (4)

Changed May 18, 2011 04:04PM UTC by anonymous comment:1

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

Changed May 18, 2011 07:34PM UTC by addyosmani comment:2

component: unfiledmisc
owner: → 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.

Changed May 20, 2011 05:45AM UTC by anonymous comment:3

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.

Changed May 20, 2011 03:15PM UTC by dmethvin comment:4

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.