Skip to content

Commit

Permalink
Merge pull request facebook#1558 from nhunzaker/fix-1530
Browse files Browse the repository at this point in the history
Fix 1530 - Asynchronously load scripts with JSX transformer
  • Loading branch information
sophiebits committed May 18, 2014
2 parents 1baca43 + bc79f62 commit 66291d2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions vendor/browser-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 66291d2

Please sign in to comment.