Skip to content

Instantly share code, notes, and snippets.

@ryanramage
Created February 14, 2014 18:08
Show Gist options
  • Save ryanramage/9005948 to your computer and use it in GitHub Desktop.
Save ryanramage/9005948 to your computer and use it in GitHub Desktop.
Use a minified require, fallback to unminified if not available
<script type="text/javascript">
function load(){
require(['js/app', 'jquery'], function (app, $) {
window.$ = $;
app.initialize();
require(['js/libs/bootstrap'], function(ihatebs){})
});
}
function loadDev(){
console.log('DEVELOPMENT MODE');
var script = document.createElement("script");
script.src = 'jam/require.js';
script.onload = load;
document.head.appendChild( script );
}
</script>
<script src="jam/require.prod.js" onerror="loadDev()" onload="load()"></script>
@ryanramage
Copy link
Author

and the commands

to minify:

./node_modules/.bin/jam compile --no-license  -i js/app  -i js/libs/bootstrap -o jam/require.prod.js

to 'unminify'

rm jam/require.prod.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment