🐛 Fix: the “type” attribute is unnecessary for JavaScript resources

The default `type` for `<script>` tags is `JavaScript`, so you don’t need to include the type for JS resources.
This commit is contained in:
Cell
2022-08-26 17:11:48 +08:00
parent 55e747e5f1
commit 2efcf947a7
7 changed files with 8 additions and 12 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -10,7 +10,7 @@
<a href="javascript:void(0);" title="{{ T `back` }}" onclick="window.history.back();"><i class="fa-regular fa-hand-point-left fa-fw"></i></a>
</p>
</article>
<script type="text/javascript">
<script>
(function() {
var emojiArray = ['\\(o_o)/', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)','(=\'X\'=)', '(>_<)', '(;-;)'];
document.getElementById('error-emoji').appendChild(document.createTextNode(emojiArray[Math.floor(Math.random() * emojiArray.length)]));
+1 -1
View File
@@ -18,7 +18,7 @@
<body data-header-desktop="{{ .Site.Params.header.desktopMode }}" data-header-mobile="{{ .Site.Params.header.mobileMode }}">
{{- /* Check theme isDark before body rendering */ -}}
{{- $theme := .Site.Params.defaulttheme -}}
<script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ $theme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ $theme }}' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>
<script>(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ $theme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ $theme }}' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>
{{- /* Body wrapper */ -}}
<div class="wrapper">
{{- partial "header.html" . -}}
+2 -2
View File
@@ -3,7 +3,7 @@
{{- if $analytics.enable -}}
{{- /* Google Analytics */ -}}
{{- with $analytics.google.id -}}
<script type="text/javascript">
<script>
window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());
gtag('config', '{{ . }}'{{ if $analytics.google.anonymizeIP }}, { 'anonymize_ip': true }{{ end }});
</script>
@@ -12,7 +12,7 @@
{{- /* Fathom Analytics */ -}}
{{- with $analytics.fathom.id -}}
<script type="text/javascript">
<script>
window.fathom=window.fathom||function(){(fathom.q=fathom.q||[]).push(arguments);};
fathom('set', 'siteId', '{{ . }}');
fathom('trackPageview');
+2 -4
View File
@@ -1,7 +1,5 @@
{{- if .Content -}}
<script type="text/javascript">
{{- .Content | safeJS -}}
</script>
<script>{{- .Content | safeJS -}}</script>
{{- else if strings.HasPrefix .Source "<script" -}}
{{- safeHTML .Source -}}
{{- else -}}
@@ -22,6 +20,6 @@
{{- end -}}
{{- $src = $resource.RelPermalink -}}
{{- end -}}
<script type="text/javascript" src="{{ $src }}"{{ if .Crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ if .Async }} async{{ end }}{{ if .Defer }} defer{{ end }}{{ with .Attr }} {{ . | safeHTMLAttr }}{{ end }}></script>
<script src="{{ $src }}"{{ if .Crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ if .Async }} async{{ end }}{{ if .Defer }} defer{{ end }}{{ with .Attr }} {{ . | safeHTMLAttr }}{{ end }}></script>
{{- end -}}
{{- end -}}
-2
View File
@@ -359,7 +359,6 @@ class FixIt {
if (searchConfig.lunrSegmentitURL && !document.getElementById('lunr-segmentit')) {
const script = document.createElement('script');
script.id = 'lunr-segmentit';
script.type = 'text/javascript';
script.src = searchConfig.lunrSegmentitURL;
script.async = true;
if (script.readyState) {
@@ -767,7 +766,6 @@ class FixIt {
const utterancesConfig = this.config.comment.utterances;
const script = document.createElement('script');
script.src = 'https://utteranc.es/client.js';
script.type = 'text/javascript';
script.setAttribute('repo', utterancesConfig.repo);
script.setAttribute('issue-term', utterancesConfig.issueTerm);
if (utterancesConfig.label) script.setAttribute('label', utterancesConfig.label);