diff --git a/assets/js/script.js b/assets/js/script.js index c3600aa..bf5f470 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -1,7 +1,15 @@ --- --- -document.addEventListener('{%- if site.turbolinks.enabled -%}turbolinks:load{%- else -%}DOMContentLoaded{%- endif -%}', () => { +const loadEvent = () => { + try { + if (Turbolinks) return 'turbolinks:load' + } catch { + return 'DOMContentLoaded' + } +} + +document.addEventListener(loadEvent(), () => { document.querySelectorAll('.share').forEach(share => { share.addEventListener('click', event => { if (!Navigator.share) return;