Jeffrey van Binsbergen.nl

The dark side of libraries

Software libraries are awesome, they add a lot of functionality within seconds to your application. However, it also comes with a few downsides. Should you really add that library to your project? Here is a small article doing my favorite thing: Nagging about using libraries inappropriate.

The right tool

Most libraries are designed with a specific use in mind, and most can be used for a lot of other purposes as well. Usually when you get creative, you may come across bugs or stuff which just isn’t possible, adding hours to your development time you thought you saved. Always see if a library is made for what you want to use it for.

Also does the library really offer you a solution you can’t make yourself within a few hours? If you want to generate a word document it is perfectly understandable, but don’t use JQuery if you just want to toggle the visibility of a text (Yes I’ve seen this being done, multiple times). You can do that with one line of native JavaScript code as well.

Resources

An obvious downside is resources: footprint, ram usage and performance. Most libraries have a bunch of code you will never use, but still get embedded in your project. Resources are still important when thinking about: Speed of initializing, low-end devices, cloud solutions (program smart or pay more) and even power consumption.

With JavaScript libraries, adding a library means more data for the browser to download when visiting your site the first time. The first visit of your visitor matters a lot. On some connections adding a library easily causes a few extra seconds of delay. Also JavaScript code is parsed on every single page request and can cause for a slow user experience. People really don’t like slow websites.

Maintainability

A thing most people don't think about is that using a library requires knowledge about that library, even if it is ‘very easy to use’. Not every library is that easy to gasp just by looking at the code. This is especially true for libraries which require usage of a specific pattern (for example KnockoutJS). Whenever someone new works on your project, they have to get familiar with all the code and libraries used which takes up time. The behavior of a library may even surprise yourself when fixing bugs.

All libraries get updated at some point because of bug fixes or new features. Upgrading may cause for problems in your project and not upgrading may leave security leaks or awful bugs in your application. You save development time, but you increase the hours you have to put in maintaining your project.

Conclusion

Libraries aren't evil but think before adding a library to your project. You may be able to stop your application to get slow, buggy and difficult to maintain just by writing a few lines of code yourself.

Show all articles