https://github.com/uetchy/prelude.js
Simple assets preloader
https://github.com/uetchy/prelude.js
Last synced: 6 months ago
JSON representation
Simple assets preloader
- Host: GitHub
- URL: https://github.com/uetchy/prelude.js
- Owner: uetchy
- License: mit
- Created: 2012-07-31T13:53:39.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T01:16:13.000Z (over 3 years ago)
- Last Synced: 2025-10-02T16:37:40.654Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 14 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# prelude.js
prelude.js is a simple and flexible preloader works with CommonJS, AMD and ``.
# Requirements
- Nothing
# Installation
```console
$ npm install --save prelude-js
```
or
```console
$ bower install --save prelude-js
```
# How to Use
```html
<script src="/path/to/prelude.js">
document.addEventListener('DOMContentLoaded', () => {
const loader = new Prelude()
loader.add([
{ from: '/images/picture.jpg' },
{ from: 'http://example.com/sample.png' },
])
loader.on('end', result => {
document.body.appendChild(result.get('picture'))
document.body.appendChild(result.get('sample'))
})
})
```
Prelude also supports CommonJS, AMD style including options. This is more modern way:
```js
const domready = require('domready')
const Prelude = require('prelude')
domready(() => {
// preload assets
const loader = new Prelude()
loader.add({ from: 'http://cdn.example.com/bgm.mp3' })
loader.on('end', result => {
// assets ready
const track = result.get('bgm')
track.play()
})
})
```
# Contributing
This is open-source project. Feel free to open new issue!
# Credits
Maintained by [Yasuaki Uechi](https://uechi.io)
Licensed under MIT License