Simpli5, an HTML5 Javascript Framework

I’ve started putting together a new HTML5 Javascript framework that is only compatible with HTML5 browsers. I’m able to have a much smaller library that way, and I’m able to do stuff I couldn’t otherwise. Like…


Because I’m using built-in Javascript methods (written in C) for many things I do, I am taking advantage of the speed of modern HTML5 browsers, without the bloat of code that makes up for missing features. Array.prototype.slice is used to convert NodeLists and Argument objects into arrays with $.toArray(); querySelector and querySelectorAll are used to quickly find the first or all matches for a given selector string. The built-in Array.prototype.forEach is used for iterating over arrays.


I can add methods to the prototype of Node and HTMLElement, giving all elements in my document functionality that I feel are common enough to be needed.

element.on('click', callback, false) // same as element.addEventListener(...) but shorter
element.addClass('my-class-name'); // hasClass, removeClass, toggleClass
element.findFirst('div .red'); element.find('li');
element.html(); element.html('<b>Hi!</b>');

And much much more.

simpl5 Element Wrapper

I’ve also create a jQuery-like class (called simpli5) which is basically an Array (uses all the native Array methods like concat, splice, forEach, map, etc.) and forwards all my calls I specify onto the elements in the array.

$('a').on('click', function(event) {
	event.preventDefault(); // real event object, don't need to fake it with a compatible browser

Class Model and EventDispatcher

I like the class model a lot. It is actually compatible with earlier browsers as well. And I do use getters/setters now that I can. I also created an EventDispatcher class that provides the addEventListener/removeEventListener/dispatchEvent, and the shortcut methods on/un.

var Foo = new Class({
	extend: EventDispatcher,
	init: function(name) {
		this._name = name;
	get name() {
		return this._name;
	set name(value) {
		if (this._name == value) return;
		var oldName = this._name;
		this._name = value;
		this.dispatchEvent(new PropertyChangeEvent('name', oldName, value));

var Bar = new Class({
	extend: Foo,
	init: function() {
		// I've found this to be the simplest most optimized (least hacky) way for overrides
		// even though the syntax with a string isn't ideal. And I've looked around.
		this.callSuper('init', 'Bar');
	// override only the getter to make it read-only
	get name() {
		return this._name;

Component Model

The part I’m most excited about is my component model. It allows you to make DOM elements become new classes. I can take a common <button id="myButton"></button> (HTMLButtonElement) element and make it become my ToggleButton component. You will even get a true when doing: document.getElementById(‘myButton’) instanceof ToggleButton. The following is a simple Button component.

var Button = new Component({
	extend: HTMLButtonElement, // be sure to extend the type you are becoming
	// the default template, true == cached (thanks ExtJS)
	// this component will become the top-level element in the template
	template: new Template('<button></button>', true),
	init: function(label) {
		if (label) this.label = label;
	get label() {
		return this.text();
	set label(value) {

// create a new button and add it into the document
var button = new Button();
button.label = "Hello World";

// turn all existing <button></button> elements into Button components

Just the Beginning

This is just the start. I’ve been borrowing ideas and code from libraries such as jQuery, mootools, prototype, and Extjs. The library is still only partial with many missing features, but it will mature, and the beginning I’ve got has been quite exciting.

11 Responses to “Simpli5, an HTML5 Javascript Framework”

  1. okela Says:

    “HTML5 browsers”, you better start using browser names, cause, like every other web “standard”, HTML5 is not cross-browsers consistent.

  2. Jacob Wright Says:

    Right now I’m testing against Chrome, Safari, and Firefox. And yes, there are some few differences, but there is a LOT less to deal with. Maybe it’s a little early for many to really be interested in HTML5-only.

  3. Simpli5, an HTML5 Javascript Framework | Dev Art Of War Says:

    […] Source […]

  4. Javascript Data Binding - Jacob Wright – Flex, AIR, PHP, etc. Says:

    […] Simpli5 has been coming along nicely as I've been able to put time into it. I'm very excited to announce data-binding. […]

  5. longhairedsi Says:

    This is top stuff, I was just researching writing my own HTML 5 Javascript library with inheritance, property change events and binding for targeting mobile webkit. Looks like I don’t need to as I found this! good work.


  6. Jacob Wright Says:

    Would love to have help.

  7. longhairedsi Says:

    I’ve forked the repo. I’ll have a play and get to know the guts of it then i’d be happy to help.


  8. Matthew Painter Says:

    This is a brilliant library, innovative, and well architected – well done :D

    When I have some free resources, this is top of my list for UX projects to support.

    Would you be interested in consulting work at all? Whereabouts are you based? Maybe we can have a chat over email? :)

    Keep up the good work!

    Matthew Painter
    CTO Kusiri

  9. HTML 5: un esquema de enlaces Says:

    […] Simpli5: […]

  10. HTML5 Lo nuevo y lo viejo | [ Between Codes and Tags ] Says:

    […] de las librerias de Javascript (El poder de frameworks como jQuery, jQuery UI, SproutCore, Simpli5, […]

  11. » HTML5, el nuevo estándar de la web / CalidadFx Says:

    […] de las librerias de Javascript (El poder de frameworks comojQuery, jQuery UI, SproutCore, Simpli5, […]