Add fonts to preloading with integrity

this is currently not supported and is ignored but it does not hurt, it
speeds up the page load and as soon as it is supported in the future it
will start to work: https://crbug.com/981419

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-09-25 02:04:19 +02:00
parent ad39d8ca23
commit ec5728b1c3
No known key found for this signature in database
GPG Key ID: 0066F03ED215AD7D
2 changed files with 16 additions and 3 deletions

View File

@ -6,9 +6,20 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{ range (list "webfonts/fa-solid-900.woff2" "webfonts/fa-brands-400.woff2" "lato-v20-latin-ext_latin-regular.woff2" "lato-v20-latin-ext_latin-700.woff2") }}
<link
as="font"
crossorigin="anonymous"
href="{{ . }}"
integrity="{{ assetSRI . }}"
rel="preload"
>
{{ end }}
<link
crossorigin="anonymous"
href="css/all.min.css"
integrity="{{ SRIHash `css/all.min.css` }}"
integrity="{{ assetSRI `css/all.min.css` }}"
rel="stylesheet"
>
@ -39,7 +50,8 @@
<div id="app"></div>
<script
integrity="{{ SRIHash `app.js` }}"
crossorigin="anonymous"
integrity="{{ assetSRI `app.js` }}"
src="app.js"
></script>
</body>

View File

@ -11,7 +11,8 @@ import (
var (
sriCacheStore = newSRICache()
tplFuncs = template.FuncMap{
"SRIHash": assetSRIHash,
"list": func(args ...string) []string { return args },
"assetSRI": assetSRIHash,
}
)