Share via

Writing code using the Windows Library for JavaScript

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]


Windows Library for JavaScript (WinJS) has a number of helper functions that you can use to define and extend JavaScript types. When you want to define new types or derive one type from another, you can use the functions in WinJS.Class. When you want to define different scopes for your JavaScript elements, you can use the functions in WinJS.Namespace.

You can also use mixins when you want to add functionality to your types. In JavaScript, mixins are types that are not instantiated and contain members that define a certain kind of behavior that can be added to multiple types. For example, a Movable mixin that contains functions goForward, goBackward, turnRight, and turnLeft can be be mixed into a number of different types, like Vehicle, Robot, and Animal. For more information about mixins, see Mixins.

In this section

Topic Description

Quickstart: Schedule tasks using WinJS

The Scheduler allows your Windows Runtime app using JavaScript to perform background work without disrupting the app's foreground tasks (like animation). This helps minimize a seemingly unresponsive or 'stuttering' experience for users and can possibly shorten startup time.

Quickstart: Use the dispose model in WinJS

Learn how to use the dispose model in WinJS to reliably control the memory usage of controls and other objects in a Windows Store app using JavaScript.

Custom types and WinJS.Class

You can use the WinJS.Class.define and WinJS.Class.derive functions to define and derive JavaScript types.

Custom namespaces and WinJS.Namespace

The WinJS.Namespace.define function allows you to create your own namespace as a way of organizing your code.

WinJS mixins

Mixins are objects that implement a certain class of functionality. For example, in the WinJS there are mixins that manage events and mixins that handle binding.

Event capture and bubbling with DOM events

In WinJS there are several addEventListener methods (for example, WinJS.Application.addEventListener and WinJS.UI.AppBar.addEventListener). They all contain a useCapture parameter, which is set to true if you want event capture or false if you want event bubbling. For more information, see Event capture and Event bubbling.