Until recently, JavaScript did not have much of a module story. In other words, there was no good way of sharing code with others. I would argue that it still doesn’t have a great one, even today. First, let’s look at the ways we share JavaScript code today. I’ll discuss why I think we are framework-heavy as a community. Finally, I’ll look at potential solutions that exist, and some of the issues they face.
An unspoken rule in the world of .js files is ”depend on no one” - that is, unless it’s jQuery.
Today, you seldomly encounter a library that requires you to download other dependencies. People are impatient, and the more stuff you ask them to do before actually seeing things happen, the less likely they are to use the library in the first place.
If a library must have dependencies, what usually happens is: either they ask you to download a .zip file that contains all of the dependencies, or they concatenate the dependencies into a monolithic file along with the library itself. You’ll see this with some libraries that depend on JSON parsing or base64 encoding, for example.
For the most part, we, the library authors, have shied away from depending on other libraries. This is a limitation. It makes it hard to stand on other’s shoulders, but it also makes it hard to reuse our own code in multiple contexts, which can be an effective way to remove code duplication. In this way, we have been handicapped for many years.
Your new post is loading...