Skip to content

Instantly share code, notes, and snippets.

@dey-dey
dey-dey / gist:10f707d6453882b2b05d
Last active August 29, 2015 14:23
Browserfiy: Require modules with aliases as shown
- js/apps/foo/index.js | require('lib/bar/beep'); require('lib/bar/beep/boop');
- js/lib/bar/beep/index.js
|----------------/boop/index.js
- package.json
"browser": {
"lib/*": "./js/lib/*"
}
@dey-dey
dey-dey / I Let Requirejs Bust my Singleton ??
Created January 14, 2014 15:24
Referencing path alias and path to said file from different modules causes anonymous define function to run twice :/
// create path for class.js
require.config({
paths: {
vvImptSingleton: 'path/to/veryImptSingleton'
}
});
// file: path/to/veryImptSingleton
@dey-dey
dey-dey / bb_inheritance_pattern.js
Created July 6, 2012 19:03
Backbone View Inheritance
var BaseView = Marionette.ItemView.extend({
tagName: 'li',
className: "class1",
template: template,
events: {
"click": "func1",
"keyup .input": "func2"
},
@dey-dey
dey-dey / gist:2559720
Created April 30, 2012 16:20 — forked from zhannes/gist:2344834
load a script
var loadScript = function(url,callback,async){
if(!url){ return false; }
var script = document.createElement('script'),
head = document.getElementsByTagName('head')[0];
script.src = url;
script.async = async ? true : false;
/* bind a callback for all browsers */