fix: dont' minimize non-javascript inline scripts

You can't add a script tag to the head which has content that is not valid JavaScript code (JSON for example).
This won't work:
```html
module.exports = {
  head: [
    ['script', { type: 'application/ld+json', '{ "foo": "bar" }']
  ]
}
```
pull/517/head
Fabian Winkler 4 years ago committed by GitHub
parent 45b65ce8b6
commit d799c260b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -182,7 +182,10 @@ function renderHead(head: HeadConfig[]): Promise<string> {
head.map(async ([tag, attrs = {}, innerHTML = '']) => {
const openTag = `<${tag}${renderAttrs(attrs)}>`
if (tag !== 'link' && tag !== 'meta') {
if (tag === 'script') {
if (
tag === 'script' &&
(attrs.type === undefined || attrs.type.includes('javascript'))
) {
innerHTML = (
await transformWithEsbuild(innerHTML, 'inline-script.js', {
minify: true

Loading…
Cancel
Save