diff --git a/assets/js/index.js b/assets/js/index.js index 03ab427..08ef756 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -22,10 +22,3 @@ $(document).keypress(function(e) { $('.modal.is-active').removeClass('is-active'); } }); - -{{ if and .Site.Params.localTime .Page.IsHome }} -$(document).ready(function() { - var time = moment().tz("{{ .Site.Params.timeZone }}").format("h:mm A"); - $('#time').html(time); -}) -{{ end }} diff --git a/assets/js/initMoment.js b/assets/js/initMoment.js new file mode 100644 index 0000000..0e8c95d --- /dev/null +++ b/assets/js/initMoment.js @@ -0,0 +1,4 @@ +$(document).ready(function() { + var time = moment().tz("{{ .Site.Params.timeZone }}").format("h:mm A"); + $('#time').html(time); +}) diff --git a/layouts/partials/footer/scripts.html b/layouts/partials/footer/scripts.html index bb81fc7..2954f7e 100644 --- a/layouts/partials/footer/scripts.html +++ b/layouts/partials/footer/scripts.html @@ -1,14 +1,14 @@ {{ $jQuery := resources.Get "vendor/jquery/jquery-3.3.1.min.js" }} -{{ $index := resources.Get "js/index.js" | resources.ExecuteAsTemplate "js/index.tmp.css" . | minify }} +{{ $index := resources.Get "js/index.js" | minify }} +{{ $scripts := slice $jQuery $index | resources.Concat "/js/bundle.js" | fingerprint }} + {{ if and .Site.Params.localTime .Page.IsHome }} {{ $momentjs := resources.Get "vendor/momentjs/moment.min.js" }} {{ $momentTimezone := resources.Get "vendor/momentjs/moment-timezone.min.js" }} {{ $momentTimezoneWithData := resources.Get "vendor/momentjs/moment-timezone-with-data-2012-2022.min.js" }} -{{ $scripts := slice $jQuery $momentjs $momentTimezone $momentTimezoneWithData $index | resources.Concat "/js/bundleMoment.js" | fingerprint }} - -{{ else }} -{{ $scripts := slice $jQuery $index | resources.Concat "/js/bundle.js" | fingerprint }} +{{ $initMomentjs := resources.Get "js/initMoment.js" | resources.ExecuteAsTemplate "js/initMoment.tmp.js" . }} +{{ $scripts := slice $momentjs $momentTimezone $momentTimezoneWithData $initMomentjs | resources.Concat "/js/bundleMoment.js" | fingerprint }} {{ end }}