perf(core): very simplistic minifier for homepage (#2630)

This commit is contained in:
Eric Dubé
2026-03-10 21:24:13 -04:00
committed by GitHub
parent e96221b0b6
commit ae96912699
@@ -283,7 +283,7 @@ export class PuterHomepageService extends BaseService {
},
};
await eventService.emit('puter.gui.addons', event);
return `<!DOCTYPE html>
let htmlOutput = `<!DOCTYPE html>
<html lang="en">
<head>
@@ -437,6 +437,24 @@ export class PuterHomepageService extends BaseService {
</body>
</html>`;
// A mostly minimal minifier that minifies minimally
// - this is NOT a general-purpose HTML minifier
// - it does not account for <pre> tags
// - it does not minify javascript code
htmlOutput = htmlOutput //...
// remove regular HTML comments, but keep conditional comments
.replace(/<!--(?!\[if[\s\S]*?]|<!|>)[\s\S]*?-->/g, '')
// collapse whitespace between tags
.replace(/>\s+</g, '><')
// collapse runs of whitespace
.replace(/\s+/g, ' ')
// remove extra space around = in attributes
.replace(/\s*=\s*/g, '=')
// remove spaces before tag close
.replace(/\s+>/g, '>')
.trim();
return htmlOutput;
};
generate_error_html ({ message }) {