Generate JS on run instead of load
This commit is contained in:
parent
352ea02d6d
commit
0e1f6f09b3
1 changed files with 16 additions and 12 deletions
|
@ -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)
|
||||
}
|
||||
|
@ -181,10 +191,10 @@ function converter(html, dynamic = true) {
|
|||
"QUOTE_COUNT": quotes.length,
|
||||
"DISCORD_STATUS": () => {
|
||||
return `<span style="color: ${constants.discStatuses[api.lanyard.discord_status].color};" class="statusColor">${constants.discStatuses[api.lanyard.discord_status].text}</span>` +
|
||||
`<style>.pfp { border-color: ${constants.discStatuses[api.lanyard.discord_status].color} }</style>`;
|
||||
`<style>.pfp { border-color: ${constants.discStatuses[api.lanyard.discord_status].color} }</style>`;
|
||||
|
||||
return "";
|
||||
},
|
||||
},
|
||||
"TOPBAR": `<div id="topbar"><h3><a href="/socials">Socials</a></h3></div>`,
|
||||
"CUSTOM_STATUS": () => {
|
||||
if (api.lanyard.activities[0] && api.lanyard.activities[0].type == 4) {
|
||||
|
@ -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]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue