Fork me on GitHub
Home What is it? Examples Getting Started Learn More Contribute Credits


Building scalable apps is fun, yeah? Download v2.7.1

What is it?

Kernel.js is an ultra lightweight (~4k) architecture for building scalable javascript applications. It provides a messaging system that allows you to build your apps in a decoupled and flexible fashion. This project was inspired by Nicholas Zakas's talk on scalable Javascript architecture.

The modules are loosely coupled. They don't communicate with each other directly.
Your hub is the messaging bus. You can also give it an api.
Kernel provides lifecycle management. It can also abstract a base library.
Optionally use a base library (such as jQuery or YUI) to handle browser normalization and ajax.

Addy Osmani used an excellent analogy when talking about this architecture. He compared it to airplanes and air traffic control. Airplanes don't interface with each other directly, they talk with air traffic control to decide when they should land and take off. The Kernel hub is like air traffic control and modules are like airplanes.


These examples illustrate how you can use Kernel.js to do simple messaging as well as advanced UI rendering and ajax. They are just examples, you can do it differently!

Getting Started

Kernel.js is extremely easy to use right out of the box but it's meant to be extended and you'll get a lot more utlity by doing so. Writing your application takes only 3 steps. If you haven't downloaded Kernel.js yet be sure to do that before you continue.

As your application grows you can always revisit any of these steps (especially the last one ;)).

Learn More

Before you begin asking questions make sure you have gone through Nicholas Zakas's talk which covers the basic premise of Kernel.js. Although Kernel.js is slightly different most of the concepts are the same.

Check out the API doc (only one page!).

Feel free to contact me with any questions. Email or visit the Google Group

What isn't Kernel.js? What are the license terms? Where should I store my data? Can I use multiple hubs? Where can I see more examples of Kernel.js?

What isn't Kernel.js?

Kernel.js isn't a framework or base library like YUI or Dojo. It's an architectural foundation that should be used in conjuction with those frameworks. Kernel.js doesn't provide any low level utilities like underscore.js, doesn't provide any DOM manipulation like jQuery, and doesn't provide any widgets like ExtJS. While Kernel.js's utility is enormous, it stops at the architectural level. To build a complex web application you'll need Kernel.js AND other libraries (base library, widget library, etc.).

What are the license terms?

Kernel.js is open source software licensed under the popular MIT license.

Where should I store my data?

That depends on your application. In some cases it makes sense to store data on the hub. For example, if you have a stream of information coming into your application (like stock quotes) you may consider storing that stream with the hub and then providing an api to access it or have the hub send notifications on its own. This works well for things like dashboards or graphs that pull from a common data source.

However, if your modules do not share data liberally it may make sense to store data on the modules. For example, you might have a module that takes data from the hub's stock ticker stream and does some number crunching on it. We'll assume that number crunching is only relevant for that module. In that case you'd store the crunched data with the module itself.

Another practice I use is to create service modules that manage various datasets. These modules are responsible for making data available to the hub so that other modules can access it.

As you can see, the data can live in more than one place. This is largely a design decision that should be based on the needs of your application.

Can I use multiple hubs?

Yes. Right now the hub implementation allows you to setup as many hubs as you want. Each module can only be attached to one hub and will only have access to the api of that hub. However, currently all modules can listen to messages from any hub.

This feature was initially put in place to support api versions (so you can run older modules in newer apps) but I am open expanding this. I've toyed with the idea of allowing a hub config that lets you restrict message routing to modules attached to that hub only. Let me know how you think it should evolve.

Where can I see more examples of Kernel.js?

Good question! I'd like to see more as well. I currently use Kernel.js on commercial projects which are unavailable to the public. If you have a project using Kernel.js that you'd like to share please let me know and I'll post it here.


Kernel.js is open source and easy to extend. Consider sharing your own extensions or improving the core itself. I am always happy to review github pull requests and I regularly respond to emails and google group posts.

If you use Kernel in one of your projects please let me know and I will add you to the examples so others can learn from your work.


While they have no affiliation with this library, many thanks should go to Nicholas Zakas (@slicknet) for the original idea and Addy Osmani (@addyosmani) for continued development of the concept.

Many thanks to Dale Herrig for the many hours of stress testing.

If you use Kernel in one of your projects please let me know and I will add you to the examples so others can learn from your work.