Javascript compression now caches

This commit is contained in:
bingus_violet 2024-06-25 18:41:15 -05:00
parent 0364cca624
commit 67d8e3bec2

View file

@ -24,6 +24,8 @@ var lastPregen = 0
var pregenFiles = []
var javascriptCache = {}
var globResult = glob.globSync("**/static/**/*.html", { absolute: true })
for (var i = 0; i < globResult.length; i++) {
var result = globResult[i]
@ -328,10 +330,13 @@ module.exports = {
if (!filePath.includes(".js")) {
data = htmlMinifier.minify(data)
} else {
data = await minify({
compressor: uglifyJs,
content: data
})
if (!javascriptCache[filePath]) {
javascriptCache[filePath] = await minify({
compressor: uglifyJs,
content: data
})
}
data = javascriptCache[filePath]
}
res.send(data)