summaryrefslogtreecommitdiff
path: root/assets/js/lines.js
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2022-12-24 15:24:34 +0100
committerRicardo Wurmus <rekado@elephly.net>2022-12-24 15:26:40 +0100
commit6622be235286747f787001e56dd483e79f319190 (patch)
tree6f9055d82d9b727300216002fa642bf5819e22b6 /assets/js/lines.js
parent350b2dfbe22bea82ca2d5739d5aebbf9277fe7b7 (diff)
Reduce page weight by simplifying line number anchors.
For large issues with many lines the DOM becomes littered with anchors that slow down rendering significantly. Dropping the anchor tags cuts the page size in half and speeds up rendering. We can still address lines by their identifiers, but to act on clicks we need a little bit of JavaScript.
Diffstat (limited to 'assets/js/lines.js')
-rw-r--r--assets/js/lines.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/assets/js/lines.js b/assets/js/lines.js
new file mode 100644
index 0000000..f22057d
--- /dev/null
+++ b/assets/js/lines.js
@@ -0,0 +1,12 @@
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3.0-or-later
+window.addEventListener('DOMContentLoaded', function () {
+ let lineClickHandler = (evt) => {
+ if (evt.target.classList.contains("line")) {
+ window.location.hash = evt.target.id;
+ return;
+ }
+ };
+ var root = document.querySelector("div.conversation");
+ root.addEventListener("click", lineClickHandler);
+});
+// @license-end