mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 11:35:40 +01:00
Optimize loading speed of the website pages
This commit is contained in:
parent
33f534fbe9
commit
825ed22017
17 changed files with 250 additions and 181 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue