Asynchronously load scripts with JSX transformer.

This commit is contained in:
Nate Hunzaker
2014-05-18 15:41:41 -04:00
parent 4558e2c4bc
commit bc79f623a1
+12 -5
View File
@@ -148,9 +148,9 @@ var load = exports.load = function(url, callback) {
xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP')
: new XMLHttpRequest();
// Disable async since we need to execute scripts in the order they are in the
// async, however scripts will be executed in the order they are in the
// DOM to mirror normal script loading.
xhr.open('GET', url, false);
xhr.open('GET', url, true);
if ('overrideMimeType' in xhr) {
xhr.overrideMimeType('text/plain');
}
@@ -182,13 +182,20 @@ runScripts = function() {
console.warn("You are using the in-browser JSX transformer. Be sure to precompile your JSX for production - http://facebook.github.io/react/docs/tooling-integration.html#jsx");
jsxScripts.forEach(function(script) {
function tick() {
if (!jsxScripts.length) return;
var script = jsxScripts.shift();
if (script.src) {
load(script.src);
load(script.src, tick);
} else {
run(script.innerHTML, null);
tick();
}
});
}
tick();
};
if (typeof window !== "undefined" && window !== null) {