Introducing WinJS

2014-04-03 00:00:00 +0100 by Alex R. Young
The WinJS documentation.

WinJS (GitHub: winjs / winjs, License: Apache 2.0) is a new UI-oriented library from Microsoft for developing cross-platform applications with JavaScript.

Microsoft have been pushing WinJS applications for a while as Windows 8 apps that are written with JavaScript instead of what we typically think of as .NET programming languages. This library is a set of UI controls that support desktop and mobile devices, and also some modern JavaScript APIs for things we've come to expect: promises, networking, data binding, and templates.

The UI style fits in with Windows 8, and although WinJS applications should run in modern browsers, there's talk of specific support for Windows Phone 8 and other Microsoft platforms in the future.

There's an announcement post on the Microsoft News Center:

Today we're also announcing that Microsoft Open Technologies has brought the Windows Library for JavaScript (WinJS) cross-platform apps and is open sourcing it under the Apache 2.0 license. Find the source code on GitHub. Use this powerful Windows development framework to build high-quality web apps across a variety of browsers and devices beyond Windows, including Chrome, Firefox, Android, and iOS.

I've been running examples on try.buildwinjs.com/ to get a feel for the API style, and it makes heavy use of promises and traditional OO wrappers:

WinJS.Binding.processAll(document.querySelector('#basicBindingOutput'), bindingSource)
  .done(function() {
    WinJS.log && WinJS.log('Binding wireup complete', 'sample', 'status');

Some corners of the UI widgets still need aesthetic attention -- the date and time pickers don't look particularly great on Chrome on my Mac. But the APIs seem consistent and similar to other popular open source projects.

If you're looking to make Windows 8-style applications and love JavaScript, then this is definitely worth following. The added benefit is you can run these web apps in non-Microsoft browsers as well.