From 7f870f5551adf445d69e75aa113d085e876a9b4f Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Sat, 10 Feb 2024 11:38:53 +0100 Subject: [PATCH] fix(head): minify tags --- src/runtime/utils/description.js | 9 +++++---- src/runtime/utils/string.js | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/runtime/utils/description.js b/src/runtime/utils/description.js index 378a5408a0..dc173944e3 100644 --- a/src/runtime/utils/description.js +++ b/src/runtime/utils/description.js @@ -1,3 +1,4 @@ +import { minify } from './string'; import { toHashHex } from '#speedkit/utils/string'; import Source from '#speedkit/components/SpeedkitImage/classes/Source'; @@ -5,7 +6,7 @@ export function getImageStyleDescription(meta, className) { return { key: className, type: 'text/css', - children: new Source(meta.value).style + children: minify(new Source(meta.value).style) }; } @@ -13,7 +14,7 @@ export function getPictureStyleDescription(metaSources, classNames) { return { key: classNames.picture, type: 'text/css', - children: metaSources.style + children: minify(metaSources.style) }; } @@ -69,13 +70,13 @@ export function getStyleDescription(children, noScript = false) { } else { return { type: 'text/css', - children + children: minify(children) }; } } export function getNoScriptDescription(textContent) { return { - innerHTML: textContent + innerHTML: minify(textContent) }; } diff --git a/src/runtime/utils/string.js b/src/runtime/utils/string.js index 5aa1b26da6..a558f56c3e 100644 --- a/src/runtime/utils/string.js +++ b/src/runtime/utils/string.js @@ -14,3 +14,10 @@ export function toHashCode(value) { export function toHashHex(value) { return toHashCode(value).toString(16); } + +export function minify(style) { + return style + .split('\n') + .map(line => line.trim()) + .join(' '); +}