diff --git a/src/app.js b/src/app.js index 1032f761d0..1bd505602e 100644 --- a/src/app.js +++ b/src/app.js @@ -444,14 +444,14 @@ var run = function () { compiler.compile(); }); - compiler.event.register('compilerLoaded', this, function (context) { - compiler.compile(); - initWithQueryParams(); + compiler.event.register('loadingCompiler', this, function (url, usingWorker) { + setVersionText(usingWorker ? '(loading using worker)' : '(loading)'); }); compiler.event.register('compilerLoaded', this, function (version) { setVersionText(version); compiler.compile(); + initWithQueryParams(); }); function initWithQueryParams () { @@ -475,8 +475,7 @@ var run = function () { $('#version').text(text); } - var loadVersion = function (version) { - setVersionText('(loading)'); + function loadVersion (version) { queryParams.update({version: version}); if (window.soljsonReleases !== undefined && window.soljsonReleases[version] !== undefined) { version = window.soljsonReleases[version]; @@ -496,7 +495,7 @@ var run = function () { } else { compiler.loadVersion(false, url); } - }; + } document.querySelector('#optimize').addEventListener('change', function () { queryParams.update({ optimize: document.querySelector('#optimize').checked }); diff --git a/src/app/compiler-worker.js b/src/app/compiler-worker.js index 14c81f0905..f6d01d668e 100644 --- a/src/app/compiler-worker.js +++ b/src/app/compiler-worker.js @@ -9,6 +9,9 @@ module.exports = function (self) { switch (data.cmd) { case 'loadVersion': delete self.Module; + // NOTE: workaround some browsers? + self.Module = undefined; + compileJSON = null; self.importScripts(data.data); diff --git a/src/app/compiler.js b/src/app/compiler.js index bdc04c4415..e182717835 100644 --- a/src/app/compiler.js +++ b/src/app/compiler.js @@ -133,6 +133,7 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) { this.loadVersion = function (usingWorker, url) { console.log('Loading ' + url + ' ' + (usingWorker ? 'with worker' : 'without worker')); + self.event.trigger('loadingCompiler', [url, usingWorker]); if (usingWorker) { loadWorker(url); @@ -143,6 +144,9 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) { function loadInternal (url) { delete window.Module; + // NOTE: workaround some browsers? + window.Module = undefined; + // Set a safe fallback until the new one is loaded setCompileJSON(function (source, optimize) { compilationFinished({error: 'Compiler not yet loaded.'});