Adding External Libraries

When developing a web based application, you would often want to include a third-party library to add functionality to your app.

If your library is available on npm you can easily add it to your project. Note that this can only be performed after checking out the project, so read the checkout tutorial before if you haven’t yet.

Packages are bundled with your project. Pay attention to their size. Adding large packages affects the loading time for your viewers. The Profiler will issue a warning in such cases.

Install packages

For example, let’s say you want to add phaser to create a video based game. To do that run the following command in the project folder:

npm install phaser --save

You’ll need to commit packagae.json file so this change will take effect when the project is published in Eko Studio.

Use packages

To use Phaser in the app.js add the following to the top of the file:

import Phaser from 'phaser';

Non npm libraries

Using npm packages is the recommended method for adding external libraries. In case npm cannot be used you can load libraries dynamically via a library such as loadjs.

Note that using these methods requires additional setup to support offline viewing in Eko’s apps. Please see using external resources to learn more.

Rate this page: X
Tell us more!