What are Plugins in Kiwi.js?

The Kiwi.js plugin facility lets developers create reusable functionality that can enhance the core Kiwi.JS library. Plugins can be very simple or very complex and may perform very specific or very general tasks. Here are some things that plugins may be used for:

  • Providing additional services such as the ability to save games.
  • Creation of specialised game objects such as a game object that provides useful functions for tower defence games.
  • Creation of functionality that can be shared by multiple game objects via the component system, such as a specialised physics system.
  • Import of assets from other systems, such as a plugin that reads a specific type of sprite sheet format.

Game developers need to know how to add and use plugins that others have developed. Plugin developers need to understand how to create plugins. Both of these topics are covered here.

Using plugins in a game

To use a plugin you need to include the plugin javascript and tell your game that you want to use the plugin.

Including the script

Plugins are packaged inside a folder. At a minimum the folder will contain one javascript file and one readme.txt file. Both the folder and the js file are named using the plugin name and version number, for example

The folder may also contain any other number of files that are used by the specific plugin.

If you want to use a plugin with Kiwi.js you need to add a script tag that references the plugin javascript. Typically your html will look very similar to this


It’s recommended that you create a plugins folder in the root of your project and place all of the plugin folders inside that folder.

Telling your game to use the plugin

Note that it is possible to create more than one game within the same webpage. Not all the games on the page may need to use the same plugins, or several games on the same page may indeed share plugins. It is desirable that each individual game uses only those plugins which are required. For this reason it is necessary to tell each game you create which plugins to use. This is done by passing in the names of the plugins via the game configuration object. The object has a property plugins, which consists of an array of strings. Each string is the name of a plugin.

Note: The name used to denote the plugin must match exactly with the Javascript object that is created by the plugin, including matching the case. Don’t confuse this with the filename of the plugin, which by convention is all lower case and includes the version number.


The readme.txt contains instructions for how to use the plugin, or a link to where the documentation resides.

Plugin Conflicts

Much like working with libraries like jquery, it is possible for two different plugins to cause conflicts and unexpected behaviour when used together. It is a good idea to test that each plugin works individually. If one or both give unexpected results when used together it is likely that there is a conflict. It’s up to you to decide what you want to do about the conflict.

Share the joy

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">