fixed CSS lazy loading (same file could be loaded multiple times)

This commit is contained in:
zadam
2019-08-30 21:22:52 +02:00
parent be477f178b
commit d4e27c1b76
4 changed files with 8 additions and 10 deletions

View File

@@ -1,9 +1,9 @@
async function requireCss(url) {
const css = Array
const cssLinks = Array
.from(document.querySelectorAll('link'))
.map(scr => scr.href);
.map(el => el.href);
if (!css.includes(url)) {
if (!cssLinks.some(l => l.endsWith(url))) {
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));
}
}