Side navigation
#11643 closed bug (wontfix)
Opened April 25, 2012 01:22PM UTC
Closed July 06, 2012 04:30AM UTC
Last modified July 06, 2012 01:01PM UTC
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
Attachments (0)
Change History (6)
Changed April 25, 2012 01:25PM UTC by comment:1
Changed April 25, 2012 01:31PM UTC by comment:2
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
Changed April 25, 2012 02:10PM UTC by comment:3
component: | unfiled → core |
---|---|
priority: | undecided → low |
status: | new → open |
Someone could take a look at this post-IIFE removal
Changed July 06, 2012 04:22AM UTC by comment:4
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 )
Changed July 06, 2012 04:30AM UTC by comment:5
resolution: | → wontfix |
---|---|
status: | open → closed |
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!
Changed July 06, 2012 01:01PM UTC by comment:6
Agreed, and thanks for doing the work antishok!
Please, see the http://jsfiddle.net/HUyQN/2/