Skip to content

Instantly share code, notes, and snippets.

@trevordixon
Created June 10, 2013 07:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevordixon/5747010 to your computer and use it in GitHub Desktop.
Save trevordixon/5747010 to your computer and use it in GitHub Desktop.
Speeding up browserify with a huge lib. Using https://github.com/ForbesLindesay/browserify-middleware with Express.
// Each of these takes just a few milliseconds
app.get('/js/main.js', browserify('./public/js/main.js', {
external: ['three'],
detectGlobals: false
}));
app.get('/js/three.js', browserify(['three'], {
noParse: ['three'], // doesn't parse to look for global vars OR calls to require; just includes as-is
cache: true, // instructs browser to cache, even in dev, because this won't be changing
debug: false // no source map
}));
// main.js requires three, and it took about 6 seconds to build
app.get('/js/main.js', browserify('./public/js/main.js'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment