From 60d814e55b289ba28ebaba6d7397c5f3c7694bb4 Mon Sep 17 00:00:00 2001 From: Danny Spina Date: Thu, 22 Jun 2023 16:49:36 +0200 Subject: [PATCH] Improve perf not blazed pages + Fix error page --- index.ts | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/index.ts b/index.ts index 91f1bd4..26696fb 100644 --- a/index.ts +++ b/index.ts @@ -144,8 +144,18 @@ app.get("/blazed", async (req, res) => { if (xhr.status !== 200) { console.error("XHR request failed:", xhr.status, xhr.statusText); - res.send(` -
+ res.send( + minify( + ` + + + + + + Blaze - error + + +

Blaze could not load the page :(

Reason: ${xhr.status} ${xhr.statusText}


@@ -157,7 +167,12 @@ app.get("/blazed", async (req, res) => {
Go back
- `); + + + `, + minifierOptions + ) + ); return; } @@ -191,8 +206,9 @@ app.get("/blazed", async (req, res) => { blazeDisclaimer.style.width = "100dvw"; blazeDisclaimer.style.border = "1px solid red"; blazeDisclaimer.style.padding = "1rem"; + blazeDisclaimer.style.textAlign = "center"; blazeDisclaimer.innerHTML = ` -

BLAZE INFO

+

BLAZE INFO

The page you are seeing could not be correctly blazed due to these webpage characteristics. Blaze served anyway a lightweight version of the page. @@ -203,7 +219,9 @@ app.get("/blazed", async (req, res) => { const referenceElement = document.body.firstChild; document.body.insertBefore(blazeDisclaimer, referenceElement); - return res.send(document.toString()); + const blazedPage = minify(document.toString(), minifierOptions); + + return res.send(blazedPage); } //TODO: find if there are more performant ways to remove images or evaluate if is the case to remove images