TimBeyer / html-to-vdom

Converts an HTML string into a virtual DOM
172 stars 41 forks source link

Remove lodash dependency for a leaner build #10

Closed jsyang closed 9 years ago

jsyang commented 9 years ago

Hi, we're optimizing the JS load and parse times for a single page app, it would be really useful if lodash was left out of the dependency tree. I think you used lodash.each(), .map() and .reduce() for compatibility reasons? I switched them to use the Array.prototype equivalent in my fork.

TimBeyer commented 9 years ago

Thanks a lot @jsyang. At first I was skeptical about whether the performance would not be worse (lodash has the reputation to often be faster than native), so I did a little jsperf at http://jsperf.com/html-to-vdom-lodash-vs-native

Seems like in almost all cases your PR actually improved speed. :)

Now I don't know if my test case is representative of real world use cases, but I'd say this is a pretty good sign.

The only remaining question would be whether the reduction in size is worth the missing backwards compatibility. virtual-dom supports many older browsers, but for example mercury does not seem to. I'd tend to say "yes". Let those old browsers die already. ;)

Maybe we'll just leave the PR open for one or two days to see if somebody objects, otherwise I'll merge this.

jsyang commented 9 years ago

Perfect, we've found the same in our user testing though I should've included a jsperf to back up the runtime performance (as you did) in my original PR comment.

Definitely +1 on letting old things go.

TimBeyer commented 9 years ago

Nobody has complained so far, so let's do this :)
I decided to make this a patch version update after some consideration, because semver is about whether code changes are necessary for keeping the library running, and not about supported environments.

TimBeyer commented 9 years ago

Published as v0.5.1

Thank you for contributing :)

jsyang commented 9 years ago

Awesome! :+1: