use trilium version number in asset paths to avoid caching issues WIP

This commit is contained in:
zadam
2022-10-26 23:50:54 +02:00
parent 441a59305b
commit b499640db8
28 changed files with 124 additions and 83 deletions

View File

@@ -86,6 +86,8 @@ async function requireLibrary(library) {
const loadedScriptPromises = {};
async function requireScript(url) {
url = window.glob.assetPath + "/" + url;
if (!loadedScriptPromises[url]) {
loadedScriptPromises[url] = $.ajax({
url: url,
@@ -97,12 +99,16 @@ async function requireScript(url) {
await loadedScriptPromises[url];
}
async function requireCss(url) {
async function requireCss(url, prependAssetPath = true) {
const cssLinks = Array
.from(document.querySelectorAll('link'))
.map(el => el.href);
if (!cssLinks.some(l => l.endsWith(url))) {
if (prependAssetPath) {
url = window.glob.assetPath + "/" + url;
}
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));
}
}