fix: ensure pageviews are fetched after DOM is loaded (#2071)

This commit is contained in:
Alexander Fuks 2024-11-30 23:07:53 +03:00 committed by GitHub
parent 2966fc174d
commit b4019f3517
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
<!-- Display GoatCounter pageviews --> <!-- Display GoatCounter pageviews -->
<script> <script>
let pv = document.getElementById('pageviews'); document.addEventListener('DOMContentLoaded', () => {
const pv = document.getElementById('pageviews');
if (pv !== null) { if (pv !== null) {
const uri = location.pathname.replace(/\/$/, ''); const uri = location.pathname.replace(/\/$/, '');
@ -16,4 +17,5 @@
pv.innerText = '1'; pv.innerText = '1';
}); });
} }
});
</script> </script>