diff --git a/build_support/editor_textarea.html b/build_support/editor_textarea.html
index aa54849a..75e30801 100644
--- a/build_support/editor_textarea.html
+++ b/build_support/editor_textarea.html
@@ -61,16 +61,24 @@ function inject() {
});
}
+// Call the inject function to load the ace files.
inject();
var textAce;
-
-setTimeout(function() {
- var t = document.querySelector("textarea");
+function initAce() {
var ace = window.__ace_shadowed__;
- textAce = ace.transformTextarea(t);
- textAce.setDisplaySettings(true);
-}, 300);
+ // Check if the ace.js file was loaded already, otherwise check back later.
+ if (ace && ace.transformTextarea) {
+ var t = document.querySelector("textarea");
+ textAce = ace.transformTextarea(t);
+ textAce.setDisplaySettings(true);
+ } else {
+ setTimeout(initAce, 100);
+ }
+}
+
+// Transform the textarea on the page into an ace editor.
+initAce();
document.getElementById("buBuild").onclick = function() {
var injectSrc = inject.toString().split("\n").join("");