Skip to content
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

Consider including Lodash in the project #124

Closed
justin808 opened this issue Oct 16, 2015 · 6 comments
Closed

Consider including Lodash in the project #124

justin808 opened this issue Oct 16, 2015 · 6 comments
Assignees
Labels

Comments

@justin808
Copy link
Member

Take a look at this:
https://github.com/shakacode/react-webpack-rails-tutorial/pull/123/files#r42269891

The take away is this:

Array.from(document.getElementsByTagName('meta')).find(tag => tag.name === 'csrf-token')

vs with Lodash:

_.find(document.querySelectorAll('meta'), 'name', 'csrf-token')

I find lodash to be my swiss army knife when coding JS, and it fits in well with React.

In fact, Lodash is already an implicit dependency.

https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/npm-shrinkwrap.json#L2669

Anybody second me?

@alexfedoseev @samnang @josiasds @mapreal19 @dylangrafmyre @rstudner?

@samnang
Copy link
Contributor

samnang commented Oct 17, 2015

👍

@justin808
Copy link
Member Author

https://www.youtube.com/watch?v=Pq1RD22W7B4#t=55s

I vote for lodash.

CC: @jdalton

@justin808
Copy link
Member Author

More on lodash: https://github.com/Khan/style-guides/pull/28/files#files

and Khan/style-guides#43

My personal preference is to lean on lodash for consistency. It's a lot of work to keep track of both, and like using the linters, I prefer consistency.

@justin808
Copy link
Member Author

@josiasds I put your name on this one. Should be quick.

@alexfedoseev if we put lodash in the vendor bundle, I'm pretty sure that parts we don't user don't get stripped out. That's a need for jQuery. I'm thinking we could have a generated/vendor-optimized.js bundle that has all the other libraries we include with unused stripped out.

I'd like to be able to see the project, non-vendor, code in it's own generated file, as that's useful for explaining what Webpack does.

@robwise
Copy link
Contributor

robwise commented Nov 2, 2015

I know it's nice to have the webpage download as small as possible, but how many KB are we talking about here? If we use half of the lodash library and leave the other half unused, we'd be foregoing, what, 9KB of savings by just importing all of it?

@justin808
Copy link
Member Author

Fixed in #147

@robwise robwise closed this as completed Nov 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants