From b9a42ffcf1f00da5011487c0992129ae90372b4c Mon Sep 17 00:00:00 2001 From: Prefetch Date: Sun, 9 Jul 2023 15:30:02 +0200 Subject: Update KaTeX and GoatCounter, fix blog post sorting --- source/infra/js/count.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'source/infra/js/count.js') diff --git a/source/infra/js/count.js b/source/infra/js/count.js index e7911ec..0271445 100644 --- a/source/infra/js/count.js +++ b/source/infra/js/count.js @@ -150,19 +150,23 @@ if (!url) return warn('not counting because path callback returned null') - var img = document.createElement('img') - img.src = url - img.style.position = 'absolute' // Affect layout less. - img.style.bottom = '0px' - img.style.width = '1px' - img.style.height = '1px' - img.loading = 'eager' - img.setAttribute('alt', '') - img.setAttribute('aria-hidden', 'true') - - var rm = function() { if (img && img.parentNode) img.parentNode.removeChild(img) } - img.addEventListener('load', rm, false) - document.body.appendChild(img) + if (navigator.sendBeacon) + navigator.sendBeacon(url) + else { // Fallback for (very) old browsers. + var img = document.createElement('img') + img.src = url + img.style.position = 'absolute' // Affect layout less. + img.style.bottom = '0px' + img.style.width = '1px' + img.style.height = '1px' + img.loading = 'eager' + img.setAttribute('alt', '') + img.setAttribute('aria-hidden', 'true') + + var rm = function() { if (img && img.parentNode) img.parentNode.removeChild(img) } + img.addEventListener('load', rm, false) + document.body.appendChild(img) + } } // Get a query parameter. @@ -267,3 +271,4 @@ goatcounter.bind_events() }) })(); + -- cgit v1.2.3