View on GitHub

JS-Class-Loader in comparison with other tools

Dojo / CommonJS / AMD

Posts like this one argue that there should not be any more script loaders, that the problem has been solved. Regardless, JS-Class-Loader exists for serious javascript developers who want to build an object-oriented codebase without having to turn every single little class into a module definition, wrap it inside an anonymous function, manually manage it's dependencies and define a function to return an instance of it. Or even worse, put all of your classes into a few massive files.

Individual classes are not modules and you should not have to define a module definition for each one. JS-Class-Loader will in future support optional AMD wrapping for sections of your codebase - either the whole thing, individual source trees in your project or branches of your namespace, but it will always use dependency detection and naming conventions to make coding inside your own codebase fast, simple and reliable.

Some developers will claim that object oriented concepts are not useful in javascript, they should perhaps consider that the reason why people shy away from it is that the tooling never existed to organise code into neat classes and not that decades of collected computer science wisdom is completely incorrect.

RequireJS

RequireJS is a popular tool for doing this sort of thing. This project addresses the same problem as RequireJS but in a different way. That problem is described very nicely here.

JS-Class-Loader has a very different approach to RequireJS. JS-Class-Loader forces you to use a set, well understood file/class/namespace structure, which means it does not need to understand javascript or read JS config blocks, which means it doesn't need to run a js interpreter with all of the complexity, overhead and extreme lack of performance that that entails.

RequireJS and similar tools are designed for the web developer who is mainly concerned with including well known libraries and plugins into their site. If your app mainly involves JQuery, JQuery plugins, a layout framework, validation libraries and your code is a bit of config and a few definitions to lay out the page then RequireJS may well solve your problem. JS-Class loader was built to support web trading front ends, where there are thousands of javascript classes defining domain models and libraries. It is most useful in projects where the developers are building their own novel javascript code, not just including and configuring other people's libraries.

Solving the wrong problem

Most of the tools out there to manage javascript try to solve the problem of installing pre-bundled 3rd party libraries into a web app. Few if any of them make it simple to build a large codebase of object oriented code. However, managing a large codebase in javascript takes a million times more work than installing some libraries. Here's how the situation generally works for large javascript development teams:

A javascript developer does not need a suite of massively complex tooling to help with the trivial task of downloading and installing a 3rd party js library. Developers need a tools that help manage complexity in their own codebase and reduce the time it takes to locate and manage classes.

GWT

GWT has advanced javascript bundling capabilities. While GWT is packed full of great tools, none of them seem to be easily separable from the core and you need to lock yourself in to GWT's IDE tools, build tools and config completely to use it, which does not appeal to a great deal of developers.

JS-Class-Loader aims to be a simple tool to do one task well, while integrating with any and all IDEs and development processes.