Javascript compression now caches
This commit is contained in:
parent
0364cca624
commit
67d8e3bec2
1 changed files with 9 additions and 4 deletions
|
@ -24,6 +24,8 @@ var lastPregen = 0
|
||||||
|
|
||||||
var pregenFiles = []
|
var pregenFiles = []
|
||||||
|
|
||||||
|
var javascriptCache = {}
|
||||||
|
|
||||||
var globResult = glob.globSync("**/static/**/*.html", { absolute: true })
|
var globResult = glob.globSync("**/static/**/*.html", { absolute: true })
|
||||||
for (var i = 0; i < globResult.length; i++) {
|
for (var i = 0; i < globResult.length; i++) {
|
||||||
var result = globResult[i]
|
var result = globResult[i]
|
||||||
|
@ -328,11 +330,14 @@ module.exports = {
|
||||||
if (!filePath.includes(".js")) {
|
if (!filePath.includes(".js")) {
|
||||||
data = htmlMinifier.minify(data)
|
data = htmlMinifier.minify(data)
|
||||||
} else {
|
} else {
|
||||||
data = await minify({
|
if (!javascriptCache[filePath]) {
|
||||||
|
javascriptCache[filePath] = await minify({
|
||||||
compressor: uglifyJs,
|
compressor: uglifyJs,
|
||||||
content: data
|
content: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
data = javascriptCache[filePath]
|
||||||
|
}
|
||||||
|
|
||||||
res.send(data)
|
res.send(data)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue