Skip to content

nandastone/precook-backbone

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 

precook-backbone

precook is a CoffeeScript preloader implementation. It currently preloads images and HTML5 videos, with the ability to add new asset loader modules.

precook was written in half a day to solve a specific problem. As such, it doesn't currently offer a great deal of flexibility. Feel free to fork or suggest improvements.

Requirements

  • jQuery
  • Backbone.js - precook has a hard dependency on Backbone.js as it mixes Backbone.Events into its objects. This could be removed by adding a simple Pubsub implementation.
  • Modernizer - used by the HTML5 video module to detect the appropriate video file to preload. If you're not loading video, this can be removed.

Getting started

  1. Define the assets to be configured. Assets are grouped for phased preloading.
  2. Define the event listeners (config loaded, preloader complete)
  3. Load the configuration into the preloader
  4. Once configuration is loaded, start preloading an asset group
  5. Do something when preloading is finished (blocking preloading), or simply do nothing (non-blocking background preloading)

Usage

precook can be configured via an external JSON configuration file, or an inline Javascript object.

preload.json

{
    "BASE_URL": "/bundles/hollerapp/assets/",
    
    "GROUPS": {
        
        "SplashScreen": [
            "img/splash/single-1.jpg",
            "video/splash.mp4"
        ],
        
        "OtherScreens": [
            "img/sprite.png"
        ]
        
    }
}

app.coffee

AssetLoader.on 'preloader:configLoaded', ->
    AssetLoader.load 'SplashScreen'

AssetLoader.on 'preloader:completed', (group) =>
    # kick off your app

About

A simple CoffeeScript preloader for Backbone projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published