Adding more and more small Javascript modules might make things easier on the developer’s end, but it might also make things slower on the user’s end. Coder Nolan Lawson set out to test how much performance was lost when dealing with not only your own modules, but also dependencies.
Lawson wrote a tool to see how many modules were included in a package, as some of them can have more than expected. Then he looked at how many modules are in popular web applications (Reddit has a staggering 1,050), and benchmarked a module importing up to 5,000 other modules.
The TLDR version is as follows, but it’s worth reading the whole post.
So there you have it: one horse-sized JavaScript duck is faster than a hundred duck-sized JavaScript horses. Despite this fact, though, I hope that our community will eventually realize the pickle we’re in – advocating for a “small modules” philosophy that’s good for developers but bad for users – and improve our tools, so that we can have the best of both worlds.
Comments
One response to “How Much Performance Are Those Small Javascript Modules Costing You?”
isn’t that what minifying and compression is for? (https://github.com/circlecell/jscompress.com)