Skip to content

Instantly share code, notes, and snippets.

View Saturate's full-sized avatar
🛠️
Building Stuff

Allan Kimmer Jensen Saturate

🛠️
Building Stuff
View GitHub Profile

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?

// method used by requirejs to decide which modules to include
// since we want to be able to package a bunch of modules in both
// public internet area as well as in edit mode
var includeModulesByFolder = function(folder, baseIncludes){
var fs = require('fs'),
glob = require('glob'),
include = [],
baseIncludes = typeof baseIncludes !== 'undefined' ? baseIncludes : [];
glob.sync( folder + '/**/*.js', { dot: false }).forEach(function(filename) {