Ticket #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: | ||
| Blocking: | Blocked by: |
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
comment:2 Changed 13 months 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 13 months ago by rwaldron
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to core
Someone could take a look at this post-IIFE removal
comment:4 Changed 11 months 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 11 months ago by mikesherov
- Status changed from open to closed
- Resolution set to wontfix
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!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Please, see the http://jsfiddle.net/HUyQN/2/