Move script to head with defer attribute set. Should give optimal performance.
This commit is contained in:
parent
929d6e7e28
commit
d8ac6ecfd0
3 changed files with 19 additions and 6 deletions
13
README.md
13
README.md
|
|
@ -32,6 +32,19 @@ This is originally a port of the [Zen](https://www.drupal.org/project/zen) theme
|
||||||
* Umbrella JS 3 (tiny jQuery replacement, 2.5kB when gzipped)
|
* Umbrella JS 3 (tiny jQuery replacement, 2.5kB when gzipped)
|
||||||
|
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
Performance should be excellent.
|
||||||
|
|
||||||
|
* Minimal and compliant HTML5
|
||||||
|
* Styles 17,7 kB (4,3 kB when gzipped)
|
||||||
|
* JavaScript 8,4 kB (2,7 kB when gzipped)
|
||||||
|
* All scripts loaded in head with "defer"
|
||||||
|
* Optimised for HTTP/2
|
||||||
|
|
||||||
|
Some performance tools will complain about to many files (js and css files are not concatenated) but with HTTP/2 that can be ignored.
|
||||||
|
|
||||||
|
|
||||||
## Sites using the Hugo Zen theme
|
## Sites using the Hugo Zen theme
|
||||||
|
|
||||||
* [Combonetwork development](https://combonet.se/) (multilingual)
|
* [Combonetwork development](https://combonet.se/) (multilingual)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
{{- partial "meta.html" . -}}
|
{{- partial "meta.html" . -}}
|
||||||
{{- partialCached "styles.html" . -}}
|
{{- partialCached "styles.html" . -}}
|
||||||
{{ block "header" . }}{{ end }}
|
{{ block "header" . }}{{ end }}
|
||||||
|
{{ partial "scripts.html" . -}}
|
||||||
{{ if and .Site.Params.piwikTrackerUrl .Site.Params.piwikSiteID }}{{ partialCached "matomo.html" . }}{{ end -}}
|
{{ if and .Site.Params.piwikTrackerUrl .Site.Params.piwikSiteID }}{{ partialCached "matomo.html" . }}{{ end -}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
@ -39,6 +40,5 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{ if $.Param "mobilemenu" }}{{ partial "mobilemenu.html" . }}{{ end -}}
|
{{ if $.Param "mobilemenu" }}{{ partial "mobilemenu.html" . }}{{ end -}}
|
||||||
{{ partial "scripts.html" . -}}
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
{{ if $.Param "jquery" -}}
|
{{ if $.Param "jquery" -}}
|
||||||
{{ $jquery := resources.Get "js/jquery.slim.min.js" | fingerprint -}}
|
{{ $jquery := resources.Get "js/jquery.slim.min.js" | fingerprint -}}
|
||||||
<script src="{{ $jquery.RelPermalink }}"></script>
|
<script defer src="{{ $jquery.RelPermalink }}"></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ $umbrella := resources.Get "js/umbrella.min.js" | fingerprint -}}
|
{{ $umbrella := resources.Get "js/umbrella.min.js" | fingerprint -}}
|
||||||
<script src="{{ $umbrella.RelPermalink }}"></script>
|
<script defer src="{{ $umbrella.RelPermalink }}"></script>
|
||||||
{{ if $.Param "mobilemenu" -}}
|
{{ if $.Param "mobilemenu" -}}
|
||||||
{{ $mobilemenu := resources.Get "js/mobile.js" | minify | fingerprint -}}
|
{{ $mobilemenu := resources.Get "js/mobile.js" | minify | fingerprint -}}
|
||||||
<script src="{{ $mobilemenu.RelPermalink }}"></script>
|
<script defer src="{{ $mobilemenu.RelPermalink }}"></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ if $.Param "contactform" -}}
|
{{ if $.Param "contactform" -}}
|
||||||
{{ $contact := resources.Get "js/contact.js" | minify | fingerprint -}}
|
{{ $contact := resources.Get "js/contact.js" | minify | fingerprint -}}
|
||||||
<script src="{{ $contact.RelPermalink }}"></script>
|
<script defer src="{{ $contact.RelPermalink }}"></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ $script := resources.Get "js/script.js" | minify | fingerprint -}}
|
{{ $script := resources.Get "js/script.js" | minify | fingerprint -}}
|
||||||
<script src="{{ $script.RelPermalink }}"></script>
|
<script defer src="{{ $script.RelPermalink }}"></script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue