Optimize loading speed of the website pages

This commit is contained in:
Alex Dima 2016-10-22 13:27:34 +02:00
parent 33f534fbe9
commit 825ed22017
17 changed files with 250 additions and 181 deletions

View file

@ -17,11 +17,12 @@ window.onload = function() {
' onError: Function;',
'};',
].join('\n'), 'require.d.ts');
var loading = document.getElementById('loading');
loading.parentNode.removeChild(loading);
load();
});
var loading = document.getElementById('loading');
loading.parentNode.removeChild(loading);
load();
});
};
@ -333,7 +334,24 @@ function doRun(runContainer) {
});
}
var preloaded = {};
(function() {
var elements = Array.prototype.slice.call(document.querySelectorAll('pre[data-preload]'), 0);
elements.forEach(function(el) {
var path = el.getAttribute('data-preload');
preloaded[path] = el.innerText || el.textContent;
el.parentNode.removeChild(el);
});
})();
function xhr(url) {
if (preloaded[url]) {
return monaco.Promise.as({
responseText: preloaded[url]
});
}
var req = null;
return new monaco.Promise(function(c,e,p) {
req = new XMLHttpRequest();