提交 799fa528 编写于 作者: M Matt Bierner

Load script async in markdown preview

上级 a67048c2
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
var marker = new ActiveLineMarker(); var marker = new ActiveLineMarker();
const settings = JSON.parse(document.getElementById('vscode-markdown-preview-data').getAttribute('data-settings')); const settings = JSON.parse(document.getElementById('vscode-markdown-preview-data').getAttribute('data-settings'));
window.addEventListener('load', () => { function onLoad() {
if (settings.scrollPreviewWithEditorSelection) { if (settings.scrollPreviewWithEditorSelection) {
const initialLine = +settings.line; const initialLine = +settings.line;
if (!isNaN(initialLine)) { if (!isNaN(initialLine)) {
...@@ -155,7 +155,14 @@ ...@@ -155,7 +155,14 @@
}, 0); }, 0);
} }
} }
}); }
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', onLoad);
} else {
onLoad();
}
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
scrollDisabled = true; scrollDisabled = true;
......
...@@ -196,7 +196,7 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv ...@@ -196,7 +196,7 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv
private getScripts(nonce: string): string { private getScripts(nonce: string): string {
const scripts = [this.getMediaPath('main.js')].concat(this.extraScripts.map(resource => resource.toString())); const scripts = [this.getMediaPath('main.js')].concat(this.extraScripts.map(resource => resource.toString()));
return scripts return scripts
.map(source => `<script src="${source}" nonce="${nonce}"></script>`) .map(source => `<script async src="${source}" nonce="${nonce}"></script>`)
.join('\n'); .join('\n');
} }
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
}); });
} }
document.addEventListener("DOMContentLoaded", function (event) { document.addEventListener('DOMContentLoaded', function (event) {
ipcRenderer.on('baseUrl', function (event, value) { ipcRenderer.on('baseUrl', function (event, value) {
initData.baseUrl = value; initData.baseUrl = value;
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册