The definitive source of the best
JavaScript libraries, frameworks, and plugins.

  • ×

    a fresh & lightweight javascript game engine
    Filed under 

    • 🔾67%Overall
    • 3,494
    • 3.7 days
    • 🕩536
    • 👥4


    Build Status Language grade: JavaScript Build Size Dependencies jsDeliver Boss Bounty Badge

    A fresh & lightweight HTML5 game engine


    Copyright (C) 2011 - 2021 Olivier Biot

    melonJS is licensed under the MIT License

    About melonJS

    melonJS is the result of our enthusiasm & experiments with Javascript, and currently features :

    • A fresh & lightweight 2D sprite-based engine
    • Standalone library (does not rely on anything else, except a HTML5 capable browser)
    • Compatible with all major browsers (Chrome, Safari, Firefox, Opera, Edge) and mobile devices
    • Fast WebGL renderer for desktop and mobile devices with fallback to Canvas rendering
    • High DPI resolution & Canvas advanced auto scaling
    • Web Audio support with fallback to Multi-channel HTML5 audio
    • Lightweight physics implementation to ensure low cpu requirements
    • Polygon (SAT) based collision algorithm for accurate detection and response
    • Fast Broad-phase collision detection using spatial partitioning
    • 3rd party tools support for physic body definition such as PhysicsEditor
    • Advanced math API for Vector and Matrix
    • Tween Effects, Transition effects
    • Basic set of Object Entities and GUI elements included
    • Pooling support for object recycling
    • Basic Particle System
    • Sprite with Animation management
    • Standard spritesheet, single and multiple Packed Textures support
    • 3rd party tools support for Texture Packing such as TexturePacker, Free Texture Packer, ShoeBox
    • A state manager (to easily manage loading, menu, options, in-game state)
    • Tiled map format version +1.0 integration for easy level design
      • Uncompressed Plain, Base64, CSV and JSON encoded XML tilemap loading
      • Orthogonal, Isometric and Hexagonal maps (both normal and staggered)
      • Multiple layers (multiple background/foreground, collision and Image layers)
      • Multiple Tileset support
      • Tileset Transparency settings
      • Layers Alpha settings
      • Rectangle, Ellipse, Polygon and Polyline objects support
      • Tiled Objects
      • Flipped & rotated Tiles
      • Dynamic Layer and Object/Group ordering
      • Dynamic Entity loading
      • Shape based Tile collision support
    • System & Bitmap fonts
    • Mouse and Touch device support (with mouse emulation)
    • Device motion & accelerometer support
    • Built-in support for 3rd party Application Wrappers such as Cordova
    • Asynchronous publish/subscribe pattern messaging support (minPubSub)
    • A fully customizable preloader
    • As light as ~70kb minified & gzipped

    Using melonJS

    Basic Example

    import * as me from "melonjs-module.js"
    me.device.onReady(function () {
        // initialize the display canvas once the device/browser is ready
        if (!, 562, {parent : "screen", scale : "auto"})) {
            alert("Your browser does not support HTML5 canvas.");
        // add a gray background to the default Stage me.ColorLayer("background", "#202020"));
        // add a font text display object me.Text(609, 281, {
            font: "Arial",
            size: 160,
            fillStyle: "#FFFFFF",
            textBaseline : "middle",
            textAlign : "center",
            text : "Hello World !"

    Simple hello world using melonJS 9.x or higher

    Documentation :

    For your first time using melonJS, follow these tutorials :

    You may find it useful to skim the overview found at the wiki Details & Usage

    When starting your own projects, checkout the boilerplate

    Download melonJS

    The latest builds with corresponding release note are available for direct download here.

    Since version 9.0.0 melonJS provides different build options :

    build description
    melonjs.js a legacy ES5 UMD Bundle (directly transpiled from the ES6 version) including full API backward compatibility with previous versions
    melonjs.min.js a minified version of the ES5 UMD bundle version
    melonjs-module.js a ES6 Module Bundle, for those living on the edge, and with no backward compatibility (note: this will break your game when upgrading!)

    Note: current version of both the tutorials and the debugPanel are not compatible with the ES6 version.

    Alternatively, the latest version of melonJS can be installed through NPM :

    $ npm install melonjs

    If you need to import the ES6 module of melonjs :

    $ import * as me from "melonjs-module.js";

    Note: when using the es6 module, deprecated methods need to be manually applied, see here

    Or can simply be added to your html, through a content delivery network (CDN) URL, using for example :

    <!-- load the ES5 UMD bundle of melonJS v9.0.0 -->
    <script src=""></script>
    <!-- load the ES6 module bundle of melonJS v9.0.0 -->
    <script src=""></script>
    <!-- omit the version completely to get the latest one -->
    <!-- you should NOT use this in production -->
    <script src=""></script>
    <!-- add ".min" to any JS/CSS file to get a minified version -->
    <script src=""></script>

    and of course the debug panel :

    <!-- load the latest debug panel -->
    <script src=""></script>
    <!-- or a specific corresponding release -->
    <script src=""></script>

    Note: "official" CDN and NPM install are only available from version 7.0.0 and onwards. Note: ES6 version of melonJS is available from version 9.0.0 and onwards.

    Building melonJS

    For most users, all you probably want is to use melonJS, and all you need then is just to download the latest built release to get started. The only time you should need to build melonJS is if you want to contribute to the project and start developing on it.

    To build your own version of melonJS you will need to install :

    • The Node.js JavaScript runtime and the NPM package manager

    Once Node.js and NPM have been installed, you need to install build dependencies, by executing the following in the folder where you cloned the repository :

    $ [sudo] npm install

    Then build the melonJS source by running:

    $ npm run build

    The generated library will be available under the build directory :

    • melonjs.js : plain ES5 UMD bundle
    • melonjs.min.js : minified ES5 UMD bundle
    • melonjs-module.js : plain ES6 module

    To run the melonJS test suite simply use the following:

    $ npm run test

    This will run the jasmine spec tests with the output displayed on the shell. Do note that the latest Chrome version is required, as the test unit will run the Browser in a headless mode (in case of failed tests, upgrade your browser).

    Building the documentation

    Similarly, you can build your own copy of the docs locally by running :

    $ npm run doc

    The generated documentation will be available in the docs directory

    WIP Builds

    melonJS uses Travis-CI for automated testing and build uploads. The latest build artifacts can be downloaded from the melonjs-builds bucket.

    Questions, need help ?

    If you need technical support, you can contact us through the following channels :

    For any other non technical related questions, feel free to also send us an email.

    Show All