feat(html/minifier): Compress more json content (#4684)

This commit is contained in:
Alexander Akait 2022-05-17 06:44:27 +03:00 committed by GitHub
parent 9a027ba7c2
commit 3aac28e9df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View File

@ -325,7 +325,10 @@ impl VisitMut for Minifier {
&& n.attributes.iter().any(|attribute| match &*attribute.name {
"type"
if attribute.value.is_some()
&& (&*attribute.value.as_ref().unwrap()) == "application/ld+json" =>
&& matches!(
&**attribute.value.as_ref().unwrap(),
"application/ld+json" | "importmap" | "speculationrules"
) =>
{
true
}

View File

@ -48,6 +48,31 @@
"prepTime": "PT20M"
}
</script>
<script type="speculationrules">
{
"prerender": [
{
"source": "list",
"urls": ["/page/2"],
"score": 0.5
},
{
"source": "document",
"if_href_matches": ["https://*.wikipedia.org/**"],
"if_not_selector_matches": [".restricted-section *"],
"score": 0.1
}
]
}
</script>
<script type="importmap">
{
"imports": {
"moment": "/node_modules/moment/src/moment.js",
"lodash": "/node_modules/lodash-es/lodash.js"
}
}
</script>
</head>
<body>
<h2>Party coffee cake recipe</h2>

View File

@ -20,6 +20,8 @@
"prepTime": "PT20M"
}
</script>
<script type=speculationrules>{"prerender":[{"score":0.5,"source":"list","urls":["/page/2"]},{"if_href_matches":["https://*.wikipedia.org/**"],"if_not_selector_matches":[".restricted-section *"],"score":0.1,"source":"document"}]}</script>
<script type=importmap>{"imports":{"lodash":"/node_modules/lodash-es/lodash.js","moment":"/node_modules/moment/src/moment.js"}}</script>
</head>
<body>
<h2>Party coffee cake recipe</h2>