Delay loading of non-essential css/js

This commit is contained in:
Rob Garrison 2018-11-25 19:24:54 -06:00
parent ed07cb8460
commit 5c38441393
2 changed files with 26 additions and 12 deletions

View File

@ -6,10 +6,10 @@
<title i18n-text="manageTitle"></title> <title i18n-text="manageTitle"></title>
<link rel="stylesheet" href="global.css"> <link rel="stylesheet" href="global.css">
<link rel="stylesheet" href="manage/manage.css"> <link rel="stylesheet" href="manage/manage.css">
<link rel="stylesheet" href="manage/config-dialog.css"> <link rel="stylesheet" data-href="manage/config-dialog.css">
<link rel="stylesheet" href="msgbox/msgbox.css"> <link rel="stylesheet" data-href="msgbox/msgbox.css">
<link rel="stylesheet" href="options/onoffswitch.css"> <link rel="stylesheet" data-href="options/onoffswitch.css">
<link rel="stylesheet" href="vendor-overwrites/colorpicker/colorpicker.css"> <link rel="stylesheet" data-href="vendor-overwrites/colorpicker/colorpicker.css">
<style id="firefox-transitions-bug-suppressor"> <style id="firefox-transitions-bug-suppressor">
/* restrict to FF */ /* restrict to FF */
@ -193,16 +193,16 @@
<script src="manage/sort.js"></script> <script src="manage/sort.js"></script>
<script src="manage/manage-ui.js"></script> <script src="manage/manage-ui.js"></script>
<script src="manage/manage-actions.js"></script> <script src="manage/manage-actions.js"></script>
<script src="manage/draggable.js"></script> <script data-src="manage/draggable.js"></script>
<script src="vendor-overwrites/colorpicker/colorconverter.js"></script> <script data-src="vendor-overwrites/colorpicker/colorconverter.js"></script>
<script src="vendor-overwrites/colorpicker/colorpicker.js"></script> <script data-src="vendor-overwrites/colorpicker/colorpicker.js"></script>
<script src="manage/config-dialog.js"></script> <script data-src="manage/config-dialog.js"></script>
<script src="manage/updater-ui.js"></script> <script src="manage/updater-ui.js"></script>
<script src="manage/object-diff.js"></script> <script data-src="manage/object-diff.js"></script>
<script src="manage/import-export.js"></script> <script data-src="manage/import-export.js"></script>
<script src="manage/incremental-search.js"></script> <script data-src="manage/incremental-search.js"></script>
<script src="msgbox/msgbox.js"></script> <script data-src="msgbox/msgbox.js"></script>
<script src="js/sections-util.js"></script> <script src="js/sections-util.js"></script>
<script src="js/storage-util.js"></script> <script src="js/storage-util.js"></script>
</head> </head>

View File

@ -33,6 +33,7 @@ Promise.all([
]).then(args => { ]).then(args => {
UI.init(); UI.init();
UI.showStyles(...args); UI.showStyles(...args);
lazyLoad();
}); });
msg.onExtension(onRuntimeMessage); msg.onExtension(onRuntimeMessage);
@ -407,3 +408,16 @@ function onVisibilityChange() {
break; break;
} }
} }
function lazyLoad() {
setTimeout(() => {
$$('link[data-href]').forEach(link => {
link.href = link.dataset.href;
link.removeAttribute('data-href');
});
$$('script[data-src]').forEach(script => {
script.src = script.dataset.src;
script.removeAttribute('data-src');
});
}, 500);
}