Why javascript libraries stink

JavaScript’s is a language everybody loves to hate, and the language which, more than any other in the modern web developer’s toolbox, people will go to insane lengths to avoid writing directly (witness Google Web Toolkit, JavaScript “helpers” in server-side frameworks, etc.).

Which isn’t fair, really, because (as I’ve said many a time) most people don’t actually hate JavaScript the language; they hate the buggy and inconsistent implementations of JavaScript in major web browsers and, to a larger extent, the buggy and inconsistent implementations of the DOM in major browsers.

Which is why as I have said before I do not like and do not advocate the use of JavaScript libraries. At first glance this may seem hypocriticial given you could argue that the LocalHero code repository is a JavaScript library in itself. However as I have said before LocalHero Code is not a library just a collection of useful functions and ways to harmonise browser behaviour. It is not an attempt to change the way the language should behave or abstract it.

In summary JavaScript on its own is a pretty good language. Which apart from browser inconsistent is very capable of being utilised to create some pretty sophisticated software without libraries. But if you net convinced here are some other reasons.

Why you should not uses libraries

1. Most libraries are bloated. The user may load a full library for effect, but in many cases the effect could be achieved in a few lines of code.

2. They unnecessarily abstract the code making debugging difficult. If something goes wrong it could be your code or the library code and it may be hard to determine which. Indeed libraries like prototype.js actually change the language behavior so much that people have likened prototype to crack cocaine.

3. Libraries remove the reason to learn JavaScript deeper. indeed because they may change language behaviour they may make it harder. As a result poorly written code proliferates this time on libraries.

4. It is really hard to create something really good with universal tool. A standalone script can generally be be optimized much better then library based one.

Aren’t actually faster

But my main problem with libraries are that for complex projects they slow down develpoment.

With ongoing complex projects you are generally extending and enhancing your work continuously. Because of this level of complexity you will generally find yourself having to understand how the entire code base (including the library) actually works. And in programming reconstructing somone elses logic can be more time consuming than actually writing it yourself. This can be even more unfortunate when if you discover there work is flawed and you DO have to write it yourself!

Bottom line don’t use JavaScript libraries.

Author: Peter Shaw

Is the founder and president of Princes Park Touch and the leader of the LocalHero project!

Fill in your details below or login