Defer website script execution
MODIFY
website/src/_includes/layouts/base.liquid
website/src/_includes/layouts/base.liquid
</footer>
{% capture script %}{% include ../scripts/index.liquid %}{% endcapture %}
- <script>{{ script | jsmin | safe }}</script>
+ <script async defer>{{ script | jsmin | safe }}</script>
</body>
</html>

MODIFY
website/src/_includes/scripts/index.js
website/src/_includes/scripts/index.js
//# Responsive width
let isMobile = false;
window.addEventListener(
- "load",
+ "DOMContentLoaded",
() => {
const mobileMatchMedia = matchMedia("(max-width: 768px)");
isMobile = mobileMatchMedia.matches;
@@ -318,7 +318,7 @@ class TableOfContents {
const toc = new TableOfContents();
window.addEventListener(
- "load",
+ "DOMContentLoaded",
() => {
toc.attach();
},

Defer website script execution (#898)