
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
@dothq/littlejsengine
Advanced tools
LittleJS is a super lightweight 2D JavaScript game engine with fast WebGL rendering. It was designed to be small, simple, and easy to use for a variety of applications from game jams to commercial releases. This engine has everything necessary to make high quality games including fast rendering, physics, particles, sound effects, music, keyboard/mouse/gamepad input handling, update/render loop, and debug tools. 🚂
![]()
It is recommended that you start by copying the LittleJS Starter Project This file is mostly empty with just a few things you can use to get started or remove. You can also download and include engine.all.js or engine.all.min.js.
In order to load files like images you will need to run a small web server like http-server on npm. I prefer to use an editor that does this for me automatically like Brackets or VS Code with the Live Server plugin.
To startup LittleJS, you must create 5 functions and pass them to engineInit. A canvas will automatically be created and added to the document. You can use this template to get started.
function gameInit()
{
// called once after the engine starts up
// setup the game
}
function gameUpdate()
{
// called every frame at 60 frames per second
// handle input and update the game state
}
function gameUpdatePost()
{
// called after physics and objects are updated
// setup camera and prepare for render
}
function gameRender()
{
// called before objects are rendered
// draw any background effects that appear behind objects
}
function gameRenderPost()
{
// called after objects are rendered
// draw effects or hud that appear above all objects
}
// startup LittleJS with your game functions after the tile image is loaded
engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, 'tiles.png');
Though not required, LittleJS is intended to be used as an object oriented system by extending the base class EngineObject with your own. This lightweight class provides many useful features including physics, collision, parent/child system, and sorted rendering. Engine objects are automatically added to the global list of objects where they will be updated and rendered until destroyed.
Here is a template you can use to make objects that behave however you want. See the examples for a complete demonstration.
class MyObject extends EngineObject
{
constructor(pos, size, tileIndex, tileSize, angle, color)
{
super(pos, size, tileIndex, tileSize, angle, color);
// your object init code here
}
update()
{
super.update(); // update object physics and position
// your object update code here
}
render()
{
super.render(); // draw object as a sprite
// your object render code here
}
}
All engine settings are in engineConfig.js. Here are the most important settings...
![]()
FAQs
LittleJS - Tiny and Fast HTML5 Game Engine
The npm package @dothq/littlejsengine receives a total of 3 weekly downloads. As such, @dothq/littlejsengine popularity was classified as not popular.
We found that @dothq/littlejsengine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.