Created
February 12, 2012 16:36
-
-
Save abernier/1809547 to your computer and use it in GitHub Desktop.
RequireJSUserScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// A module that can greet (depends on speech) | |
// | |
define(['speech'], function (speech) { | |
return { | |
hi: function () {speech.say('hi!');} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @id requirejsuserscript | |
// @name RequireJSUserScript | |
// @author Antoine BERNIER (abernier) | |
// @version 0.0.1 | |
// @description UserScript with requireJS | |
// ==/UserScript== | |
(function (d, cb) { | |
// | |
// RequireJS over here! | |
// | |
if (typeof window.requirejs === 'undefined') { | |
var s; | |
s = d.createElement('script'); | |
s.src = 'https://raw.github.com/jrburke/requirejs/master/require.js'; | |
s.onload = function () { | |
var s; | |
s = d.createElement('script'); | |
s.textContent = '(' + cb.toString() + ')(requirejs);'; | |
d.body.appendChild(s); | |
} | |
d.body.appendChild(s); | |
} else { | |
cb(requirejs) | |
} | |
}(document, function (require) { | |
require.config({ | |
paths: { | |
cs: 'https://raw.github.com/jrburke/require-cs/master/cs' | |
}, | |
baseUrl: "https://raw.github.com/gist/1809547" | |
}); | |
require(['cs!index']); | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
Main | |
### | |
require(['greetings'], (greetings) -> | |
greetings.hi() | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Main | |
// | |
require(['greetings'], function(greetings) { | |
greetings.hi(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// A module that can speak | |
// | |
define({ | |
say: function () {return console.log.apply(console, arguments);} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment