-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go on a Diet #2060
Comments
Theres better ways to do this than deleting methods. |
Oh didn't see this one:
|
I'd be happy to spend a few hours looking for places to trim down (I'm sure others would too). However, no one was given the opportunity. I know what the answer is going to be to this, but please mark 1.7 as latest on npm and revert 1.8 before people start using it. |
Also ping #1594 |
Could we look for some features in underscore that could be moved to underscore-contrib? |
FYI Underscore is now 6kb gzipped, which is up from 5.8kb for v1.8.3 (site says 5.7kb). |
Im sure there is an excellent reason for this, and id love to hear it but wouldn't it save quite a bit of size if Underscore used more of its own functions internally? such as At quick glance it seems there a quite a few more places that Underscore could "Dog Food" itself. One of the things I love about Underscore is how it decreases the amount of Javascript I write in my projects. Seems Underscore itself could take more advantage of that. |
My guess is it's a concern over performance. That said I'm sure there are plenty of methods where performance isn't a concern for their common usage scenarios. It would be worth reviewing areas where dog fooding can be improved, nixing those areas where perf flags are raised. |
These two functions were nearly identical. Inspired by jashkenas#2060, I thought I would try to combine the two to save some bytes. Ironically, repetitive code gzips very well, so this refactor actually ends up _adding_ 3 bytes to the minified-gzipped size. Oh well. Never the less, I figured I'd open the PR, since it does reduce repetition in the source code, and maybe it will serve as a guide for somebody else who looks into combing these. Pros: * Less code in underscore.js * DRYer code (https://en.wikipedia.org/wiki/Don't_repeat_yourself) Cons: * Larger gzipped file size * Possibly a _tiny_ bit slower (I'm no perf expert) * Code is harder to understand
These two functions were nearly identical. Inspired by jashkenas#2060, I thought I would try to combine the two to save some bytes. Ironically, repetitive code gzips very well, so this refactor actually ends up _adding_ 3 bytes to the minified-gzipped size. Oh well. Never the less, I figured I'd open the PR, since it does reduce repetition in the source code, and maybe it will serve as a guide for somebody else who looks into combing these. Pros: * Less code in underscore.js * DRYer code (https://en.wikipedia.org/wiki/Don't_repeat_yourself) Cons: * Larger gzipped file size * Possibly a _tiny_ bit slower (I'm no perf expert) * Code is harder to understand
These two functions were nearly identical. Inspired by jashkenas#2060, I thought I would try to combine the two to save some bytes. Ironically, repetitive code gzips very well, so this refactor actually ends up _adding_ 3 bytes to the minified-gzipped size. Oh well. Never the less, I figured I'd open the PR, since it does reduce repetition in the source code, and maybe it will serve as a guide for somebody else who looks into combing these. Pros: * Less code in underscore.js * DRYer code (https://en.wikipedia.org/wiki/Don't_repeat_yourself) Cons: * Larger gzipped file size * Possibly a _tiny_ bit slower (I'm no perf expert) * Code is harder to understand
These two functions were nearly identical. Inspired by jashkenas#2060, I thought I would try to combine the two to save some bytes. Ironically, repetitive code gzips very well, so this refactor actually ends up _adding_ 3 bytes to the minified-gzipped size. Oh well. Never the less, I figured I'd open the PR, since it does reduce repetition in the source code, and maybe it will serve as a guide for somebody else who looks into combing these. Pros: * Less code in underscore.js * DRYer code (https://en.wikipedia.org/wiki/Don't_repeat_yourself) Cons: * Larger gzipped file size * Possibly a _tiny_ bit slower (I'm no perf expert) * Code is harder to understand
Saves 4 bytes gzipped, and I don't find it any harder to read. One minuscule step toward jashkenas#2060
The way a code change maps to a change in minified/gzipped size is not always intuitive (jashkenas#2383). To help folks in our effort to slim down (jashkenas#2060), they can now issue the command: npm run weight And get output like: 6.27 kB Which should give a fairly good estimate of the "over-the-wire" size of their `underscore.js`. Caveat: The weight reported does not include the source-map comment at the end of the file.
Underscore is getting a little chunky around the edges...
We're up to 5.8k, minified and gzipped. It would be lovely to get that back down under 5...
The text was updated successfully, but these errors were encountered: