refactor(repo-card): use iife and async loading
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
async function fetchRepo() {
|
(async () => {
|
||||||
const script = document.currentScript;
|
const script = document.currentScript;
|
||||||
const repoURL = script?.getAttribute("data-repo-url");
|
const repoURL = script?.getAttribute("data-repo-url");
|
||||||
const repoId = script?.getAttribute("data-repo-id");
|
const repoId = script?.getAttribute("data-repo-id");
|
||||||
@@ -54,6 +54,4 @@ async function fetchRepo() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
})();
|
||||||
|
|
||||||
fetchRepo();
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
||||||
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
||||||
<script
|
<script
|
||||||
|
async
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="{{ $fetchRepo.RelPermalink }}"
|
src="{{ $fetchRepo.RelPermalink }}"
|
||||||
integrity="{{ $fetchRepo.Data.Integrity }}"
|
integrity="{{ $fetchRepo.Data.Integrity }}"
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
||||||
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
||||||
<script
|
<script
|
||||||
|
async
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="{{ $fetchRepo.RelPermalink }}"
|
src="{{ $fetchRepo.RelPermalink }}"
|
||||||
integrity="{{ $fetchRepo.Data.Integrity }}"
|
integrity="{{ $fetchRepo.Data.Integrity }}"
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
||||||
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
||||||
<script
|
<script
|
||||||
|
async
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="{{ $fetchRepo.RelPermalink }}"
|
src="{{ $fetchRepo.RelPermalink }}"
|
||||||
integrity="{{ $fetchRepo.Data.Integrity }}"
|
integrity="{{ $fetchRepo.Data.Integrity }}"
|
||||||
|
|||||||
@@ -68,6 +68,7 @@
|
|||||||
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
||||||
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
||||||
<script
|
<script
|
||||||
|
async
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="{{ $fetchRepo.RelPermalink }}"
|
src="{{ $fetchRepo.RelPermalink }}"
|
||||||
integrity="{{ $fetchRepo.Data.Integrity }}"
|
integrity="{{ $fetchRepo.Data.Integrity }}"
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
|
||||||
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
|
||||||
<script
|
<script
|
||||||
|
async
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="{{ $fetchRepo.RelPermalink }}"
|
src="{{ $fetchRepo.RelPermalink }}"
|
||||||
integrity="{{ $fetchRepo.Data.Integrity }}"
|
integrity="{{ $fetchRepo.Data.Integrity }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user