From 0e1f6f09b32f360611c653fcdbb98f983b663c07 Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Wed, 26 Jun 2024 05:09:19 -0500 Subject: [PATCH] Generate JS on run instead of load --- pageUpdater.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pageUpdater.js b/pageUpdater.js index eed88eb..ab333e5 100644 --- a/pageUpdater.js +++ b/pageUpdater.js @@ -36,6 +36,16 @@ for (var i = 0; i < globResult.length; i++) { }) } +(async function() { + globResult = glob.globSync("**/static/**/*.js", { absolute: true }) + for (var i = 0; i < globResult.length; i++) { + javascriptCache[globResult[i]] = await minify({ + compressor: uglifyJs, + content: fs.readFileSync(globResult[i]).toString() + }) + } +})() + function firstToUpper(str) { return str.charAt(0).toUpperCase() + str.slice(1) } @@ -179,12 +189,12 @@ function converter(html, dynamic = true) { }, "COMMIT_COUNT": commitCount, "QUOTE_COUNT": quotes.length, - "DISCORD_STATUS": () => { + "DISCORD_STATUS": () => { return `${constants.discStatuses[api.lanyard.discord_status].text}` + - ``; - + ``; + return ""; - }, + }, "TOPBAR": `

Socials

`, "CUSTOM_STATUS": () => { if (api.lanyard.activities[0] && api.lanyard.activities[0].type == 4) { @@ -197,7 +207,7 @@ function converter(html, dynamic = true) { addedHTML += status.emoji.name + " " } } - + addedHTML += makeHtmlSafe(status.state) addedHTML += "

" return addedHTML @@ -331,12 +341,6 @@ module.exports = { if (!filePath.includes(".js")) { data = htmlMinifier.minify(data) } else { - if (!javascriptCache[filePath]) { - javascriptCache[filePath] = await minify({ - compressor: uglifyJs, - content: data - }) - } data = javascriptCache[filePath] } @@ -389,7 +393,7 @@ api.events.on("lanyardUpdate", async () => { if (!api.lanyard.activityChanged) { pregenerate() } - + for (var i = 0; i < api.lanyard.activities.length; i++) { var activity = api.lanyard.activities[i] if (activity.type == 4 && activity.emoji) {