This one has been slow-cooking since February and it’s good. For the first time in a while, this release focuses on adding some significant new features to Knockout. Almost any developer using KO should seriously consider making use of these, as they can greatly streamline your code.

So what’s new?

Components

Components bring a new and hugely more scalable way of structuring a large application. They:

Combine a viewmodel and template in an encapsulated package

Can represent either small reusable widgets or entire sections/pages in a larger app

Can be preloaded, or loaded on demand

Can be nested or inherited

Can work with custom conventions for configuration or loading.

I’ve built a few apps with KO components recently (including the KO triage site, and an iOS/Android game called Blockpick (not open source)) and can confidently say this is how I’ll be structuring my KO apps from now on.

Custom elements

Custom elements provide many of the benefits of the emerging Web Components spec, but cleanly integrated with KO’s new components feature described above. Plus, they’re ready to use in production today – compatible all the way back to IE6!

Pure computeds

ko.computed has always been the powerhouse behind KO, underpinning just about all of its features. It makes your code reactive without you having to declare any dependencies explicitly.

ko.pureComputed is a new specialisation of ko.computed with better performance and memory management in many cases. It automatically pauses/resumes evalution, and automatically releases/reclaims references to dependencies, according to whether any other part of your app is watching it at the time. This can be extremely valuable for large single-page applications, where you may be tearing down and rebuilding different parts of your UI over long periods of time, and need to ensure your memory/CPU use is as streamlined as possible.

The textInput binding

This new binding transparently resolves numerious browser event quirks related to text entry. You might not believe how many different types of events are raised (or worse: not raised) by different browsers when a user types, cuts, pastes, drags, or autocompletes text in an <input> or <textarea>. Or if you’ve been a web developer for a while, you probably would believe it, and have the battle scars to show.

Well, textInput is something of an expert on the subject, so hopefully you don’t have to be.

More

Hopefully these enhancements will prove valuable for your projects. I’ve been using most of them for a while and have certainly found them useful. Big thanks to everyone who’s participated in implementing and discussing these changes!

Last week in Oslo I was lucky enough to attend the fantastic NDC 2014 conference, at which I gave the following talk about using brand-new not-yet-released Knockout.js features, along with Yeoman, Gulp, and Karma to build large single-page web apps in a very modern style (while still retaining backward compatibility all the way to IE 6!).

This should be of interest to anyone who uses Knockout or cares about scalable front-end architecture.

Contents

00:00 Benefits and challenges of single-page apps; relevance of Knockout.js

Watch the video

Last week in Oslo I was lucky enough to attend the fantastic NDC 2014 conference, at which I gave the following talk about using WebGL to make browsers do cool and unusual things. If you’re interested in pushing the web platform to its edge, check it out.