From 0d44f8e4610cc30ee57ee28cc78dda929da9708c Mon Sep 17 00:00:00 2001 From: Conrad Zelck <git@simpel.cc> Date: Fri, 23 Feb 2024 00:44:34 +0100 Subject: [PATCH] feat: defer script and style in head That makes it possible to see pre-rendered content on very slow networks extremely earlier. Signed-off-by: Conrad Zelck <git@simpel.cc> --- index.php | 8 ++------ script.js | 5 +++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 46b2a8b..19138d3 100644 --- a/index.php +++ b/index.php @@ -4,8 +4,8 @@ <?php include dirname($_SERVER['DOCUMENT_ROOT']) . "/simpel.cc/php/head.php"; ?> <!-- <meta charset="utf-8"> --> <!-- <title>FreqBuddy</title> --> - <script src="script.js"></script> - <link rel="stylesheet" href="style.css"> + <script src="script.js" defer></script> + <link rel="stylesheet" href="style.css" defer> </head> <body> <header> @@ -154,8 +154,4 @@ <div class="space"></div> </main> </body> - <script> - enableCellPopup(); - calculateFreqs(); - </script> </html> diff --git a/script.js b/script.js index 9eebaaa..b94c136 100644 --- a/script.js +++ b/script.js @@ -218,3 +218,8 @@ function getCookie(cname) { } return ""; } + +document.addEventListener('DOMContentLoaded', function() { + enableCellPopup(); + calculateFreqs(); +}); -- GitLab