Skip to content

Commit f817a29

Browse files
committed
loading improvements
1 parent 2de08c3 commit f817a29

13 files changed

Lines changed: 2807 additions & 44 deletions

File tree

public/.DS_Store

6 KB
Binary file not shown.

public/asset-manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"core.min.js": "core.3db744fc07.min.js",
3+
"vendor.min.js": "vendor.9df222182a.min.js",
4+
"mermaid.min.js": "mermaid.f848a72d16.min.js",
5+
"all.min.css": "all.8d9fbb7ca6.min.css"
6+
}

public/imgs/anonymize.png

-94 KB
Loading

public/imgs/dashboard.png

-79.4 KB
Loading

public/imgs/explorer.png

-121 KB
Loading

public/imgs/screenshot.png

-76.9 KB
Loading

public/index.html

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- index.html -->
22
<!DOCTYPE html>
3-
<html lang="en" ng-app="anonymous-github" ng-controller="mainController">
3+
<html lang="en" ng-controller="mainController">
44
<head>
55
<meta charset="UTF-8" />
66
<meta
@@ -38,8 +38,16 @@
3838
<link
3939
rel="stylesheet"
4040
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&display=swap"
41+
media="print"
42+
onload="this.media='all'"
4143
/>
42-
<link rel="stylesheet" href="/css/all.min.css" />
44+
<noscript>
45+
<link
46+
rel="stylesheet"
47+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&display=swap"
48+
/>
49+
</noscript>
50+
<link rel="stylesheet" href="/css/__ALL_CSS__" />
4351
</head>
4452
<body keypress-events class="d-flex flex-column">
4553
<ng-include src="'partials/header.htm'"></ng-include>
@@ -74,26 +82,51 @@
7482
</div>
7583
</div>
7684

77-
<script src="/script/bundle.min.js"></script>
85+
<script src="/script/__CORE_JS__"></script>
7886
<script>
79-
ace.config.set("basePath", "/script/external/ace/");
80-
PDFJS.workerSrc = "/script/external/pdf.worker.js";
87+
// Lazy-load mermaid only when a mermaid diagram is encountered
88+
window.loadMermaid = function () {
89+
if (window._mermaidLoaded || window._mermaidLoading) return;
90+
window._mermaidLoading = true;
91+
var s = document.createElement("script");
92+
s.src = "/script/__MERMAID_JS__";
93+
s.onload = function () {
94+
window._mermaidLoaded = true;
95+
window._mermaidLoading = false;
96+
if (typeof mermaid !== "undefined") {
97+
mermaid.initialize({ startOnLoad: false, theme: "default", securityLevel: "loose" });
98+
window.mermaidInitialized = true;
99+
var els = document.querySelectorAll(".mermaid:not([data-processed])");
100+
if (els.length) mermaid.init(undefined, els);
101+
}
102+
};
103+
document.body.appendChild(s);
104+
};
81105
</script>
82-
<script src="https://storage.ko-fi.com/cdn/scripts/overlay-widget.js"></script>
106+
<script src="/script/__VENDOR_JS__" defer onload="
107+
ace.config.set('basePath', '/script/external/ace/');
108+
PDFJS.workerSrc = '/script/external/pdf.worker.js';
109+
angular.bootstrap(document, ['anonymous-github']);
110+
"></script>
83111
<script>
84-
(function () {
85-
var isDark = localStorage.getItem("darkMode") === "true";
86-
kofiWidgetOverlay.draw("tdurieux", {
87-
type: "floating-chat",
88-
"floating-chat.donateButton.text": "Support me",
89-
"floating-chat.donateButton.background-color": isDark
90-
? "#FAF9F6"
91-
: "#1A1815",
92-
"floating-chat.donateButton.text-color": isDark
93-
? "#1A1815"
94-
: "#FAF9F6",
95-
});
96-
})();
112+
window.addEventListener("load", function () {
113+
var s = document.createElement("script");
114+
s.src = "https://storage.ko-fi.com/cdn/scripts/overlay-widget.js";
115+
s.onload = function () {
116+
var isDark = localStorage.getItem("darkMode") === "true";
117+
kofiWidgetOverlay.draw("tdurieux", {
118+
type: "floating-chat",
119+
"floating-chat.donateButton.text": "Support me",
120+
"floating-chat.donateButton.background-color": isDark
121+
? "#FAF9F6"
122+
: "#1A1815",
123+
"floating-chat.donateButton.text-color": isDark
124+
? "#1A1815"
125+
: "#FAF9F6",
126+
});
127+
};
128+
document.body.appendChild(s);
129+
});
97130
</script>
98131
</body>
99132
</html>

public/partials/home.htm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ <h2 class="featurette-heading">Double-anonymous</h2>
193193
<div class="col-md-5 order-md-1">
194194
<img
195195
width="500"
196+
loading="lazy"
196197
src="/imgs/anonymize.png"
197198
class="featurette-image img-fluid mx-auto"
198199
alt="Anonymize form"
@@ -214,6 +215,7 @@ <h2 class="featurette-heading">Explorer</h2>
214215
<div class="col-md-5">
215216
<img
216217
width="500"
218+
loading="lazy"
217219
src="/imgs/explorer.png"
218220
class="featurette-image img-fluid mx-auto"
219221
alt="Repository explorer"
@@ -234,6 +236,7 @@ <h2 class="featurette-heading">Manage</h2>
234236
<div class="col-md-5 order-md-1">
235237
<img
236238
width="500"
239+
loading="lazy"
237240
src="/imgs/dashboard.png"
238241
class="featurette-image img-fluid mx-auto"
239242
alt="Dashboard"

public/script/core.min.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/script/external/marked-mermaid.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,35 @@ function markedMermaid(options) {
2424
renderer(token) {
2525
const id = 'mermaid-' + Math.random().toString(36).substr(2, 9);
2626

27-
// Initialize Mermaid if not already done
28-
if (typeof mermaid !== 'undefined' && !window.mermaidInitialized) {
29-
mermaid.initialize({
30-
startOnLoad: false,
31-
theme: 'default',
32-
securityLevel: 'loose'
33-
});
34-
window.mermaidInitialized = true;
35-
}
36-
3727
// Create a div that will be processed by Mermaid
3828
const div = `<div class="mermaid" id="${id}">${token.text}</div>`;
39-
29+
30+
// Trigger lazy-load of mermaid if not yet loaded
31+
if (typeof mermaid === 'undefined' && typeof window.loadMermaid === 'function') {
32+
window.loadMermaid();
33+
}
34+
4035
// Schedule Mermaid rendering for after DOM insertion
4136
setTimeout(() => {
42-
if (typeof mermaid !== 'undefined') {
43-
try {
44-
const element = document.getElementById(id);
45-
if (element && !element.getAttribute('data-processed')) {
46-
mermaid.init(undefined, element);
47-
element.setAttribute('data-processed', 'true');
48-
}
49-
} catch (error) {
50-
console.error('Mermaid rendering error:', error);
37+
if (typeof mermaid === 'undefined') return;
38+
if (!window.mermaidInitialized) {
39+
mermaid.initialize({
40+
startOnLoad: false,
41+
theme: 'default',
42+
securityLevel: 'loose'
43+
});
44+
window.mermaidInitialized = true;
45+
}
46+
try {
47+
const element = document.getElementById(id);
48+
if (element && !element.getAttribute('data-processed')) {
49+
mermaid.init(undefined, element);
50+
element.setAttribute('data-processed', 'true');
5151
}
52+
} catch (error) {
53+
console.error('Mermaid rendering error:', error);
5254
}
53-
}, 0);
55+
}, 100);
5456

5557
return div;
5658
}

0 commit comments

Comments
 (0)