Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#11643 closed bug (wontfix)

USING VARIABLE TO REPLACE REDUPLICATE STRINGS

Reported by: snandy Owned by:
Priority: low Milestone: None
Component: core Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

When reading jQuery source code I found many reduplicate strings such as "string", "object". For example, "string" is appears 44 times in jQuery-1.7.2.js. if we use variable to replace it then the compressed file will be more small.

The following is the number of occurrences of each string.


"string": 44
"object": 18
"undefined": 18
"input": 17
"fx": 13
"div": 12
"script": 11
"number": 10
"px": 10
"radio": 9
"hide": 9
"none": 9
"width": 9
"show": 9
"checkbox": 8
"toggle": 7
"button": 7
"height": 7
"display": 7
"function": 7
"fxshow": 6
"id": 6
"get": 6
"body": 5
"boolean": 5
"href": 5
"olddisplay": 5
"opacity": 5
"hidden": 5
"type": 4
"GET": 4
".run": 4
"padding": 4
"margin": 4
"fixed": 4
"inline": 4
"border": 4
"static": 3
"marginTop": 3
"parentNode": 3
"marginLeft": 3
"nextSibling": 3
"relative": 3


Change History (6)

comment:1 Changed 10 years ago by snandy

comment:2 Changed 10 years ago by mikesherov

I like this thought, but what's interesting is that gzip actually might NOT like it. Definitely worth exploring some of the egregious ones like "string", and just seeing what the effect would be

comment:3 Changed 10 years ago by Rick Waldron

Component: unfiledcore
Priority: undecidedlow
Status: newopen

Someone could take a look at this post-IIFE removal

comment:4 Changed 10 years ago by antishok

Making this change for "string" and "object", grunt says:

Sizes - compared to master
    255642       (-72)  dist/jquery.js                                         
     91985      (-259)  dist/jquery.min.js                                     
     33139        (-2)  dist/jquery.min.js.gz

Is this worth pursuing any further? rwaldron, may I ask what you mean by post-IIFE removal?

(trying to be helpful, but if I'm not, kindly shove me off :P )

comment:5 Changed 10 years ago by mikesherov

Resolution: wontfix
Status: openclosed

antishok, thanks for doing the investigative work, but if this only saves us 2 bytes, I think we should scrap the idea. As I mentioned earlier in this thread, gzip is already great at minimizing the impact of repeated strings of text, and your research proves it. I think we can safely close this ticket as wontfix.

Please feel free to tackle any other bugs you'd like, and thanks again for your help!

comment:6 Changed 10 years ago by dmethvin

Agreed, and thanks for doing the work antishok!

Note: See TracTickets for help on using tickets.