Configure asset preloading and caching for web deployment
When releasing your game online, asset loading is one of the most important issues to solve. Monogatari's built-in preloading ensures players can enjoy your game even on slow connections.
Settings Overview
Setting
Type
Default
Description
Preload
boolean
true
Enable/disable asset preloading
ServiceWorkers
boolean
true
Enable service worker caching
Built-In Preloading
The preloading screen shows a progress bar while assets are loaded before the game starts.
Enable Preloading (Default)
monogatari.settings({'Preload':true});
With preloading enabled:
A loading screen appears when entering the game
Assets are loaded before gameplay begins
Players experience smooth gameplay without loading delays
The default Preload Block
For optimal performance, define a default preload block to specify exactly which assets should be preloaded at startup:
With a default block:
Only specified assets are preloaded (faster initial load)
Audio is decoded to AudioBuffers (instant playback)
Images are pre-decoded (no rendering delay)
Without a default block (legacy behavior):
ALL registered assets are preloaded to browser cache
Assets are fetched but not decoded until first use
// The name of your game (no spaces or special characters)
const name = 'MyVisualNovel';
// Cache version - change to force re-caching all assets
const version = '0.1.0';
Service Workers are available only when serving your files through a server.
monogatari.script({
'Start': [
// Preload assets for the next scene
'preload scene forest',
'preload music theme',
'show scene bedroom',
'y Let me tell you about the forest...',
// Forest assets are now ready
'show scene forest',
'end'
]
});