Add a early js script.

This commit is contained in:
Fredrik Jonsson 2020-08-24 02:08:30 +02:00
commit 88054afa22
3 changed files with 16 additions and 2 deletions

13
assets/js/script-early.js Normal file
View file

@ -0,0 +1,13 @@
/**
* @file
* A JavaScript file for the theme. Runs first, before jQuery etc. have loaded.
*/
(function () {
'use strict';
// Add a js class to the html-tag when JavsScript is active.
document.querySelector('html').classList.replace('nojs', 'js');
})();

View file

@ -7,7 +7,6 @@
'use strict';
// Add a js class to the html-tag when JavsScript is active.
$('html').removeClass('nojs').addClass('js');
// Place your code here.
})(u);

View file

@ -1,3 +1,5 @@
{{ $early := resources.Get "js/script-early.js" | minify | fingerprint -}}
<script src="{{ $early.RelPermalink }}"></script>
{{ if $.Param "jquery" -}}
{{ $jquery := resources.Get "js/lib/jquery.slim.min.js" | fingerprint -}}
<script defer src="{{ $jquery.RelPermalink }}"></script>