diff options
author | Prefetch | 2023-07-09 15:30:02 +0200 |
---|---|---|
committer | Prefetch | 2023-07-09 15:30:02 +0200 |
commit | b9a42ffcf1f00da5011487c0992129ae90372b4c (patch) | |
tree | 4734d8b8ec979fcfa2463f6cf57768625e0bb353 /source/infra/js/count.js | |
parent | 7530507686858f7b49a8be4fca4f5c55483e8b4f (diff) |
Update KaTeX and GoatCounter, fix blog post sorting
Diffstat (limited to 'source/infra/js/count.js')
-rw-r--r-- | source/infra/js/count.js | 31 |
1 files changed, 18 insertions, 13 deletions
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() }) })(); + |