Skip to content

Instantly share code, notes, and snippets.

@opsb
Created June 5, 2012 14:28
Show Gist options
  • Select an option

  • Save opsb/2875351 to your computer and use it in GitHub Desktop.

Select an option

Save opsb/2875351 to your computer and use it in GitHub Desktop.
Fix for using require.js in chrome plugin
require.attach = function (url, context, moduleName, onScriptLoad, type, fetchOnlyFunction) {
var xhr;
onScriptLoad = onScriptLoad || function () {
context.completeLoad(moduleName);
};
xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function (e) {
if (xhr.readyState === 4 && xhr.status === 200) {
eval(xhr.responseText);
onScriptLoad();
}
};
xhr.send(null);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment