From 4822793af9b83ba9e0cac1248fd630fd7f2b12a6 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 27 Aug 2017 19:47:29 +0100 Subject: [PATCH] Fix blocking Javascript --- _includes/footer.html | 4 ++-- static/script.js | 37 ++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/_includes/footer.html b/_includes/footer.html index 921e815..be22a29 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -1,7 +1,7 @@ - - + + diff --git a/static/script.js b/static/script.js index 706dd3e..947d416 100644 --- a/static/script.js +++ b/static/script.js @@ -1,19 +1,30 @@ // @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0 // This script is licensed under CC0 -$(function() { - $("#printable").click(function() { - $("body").addClass("printable"); - }); - - return $("h2, h3, h4, h5, h6").each(function(i, el) { - var $el, icon, id; - $el = $(el); - id = $el.attr('id'); - if (id) { - return $el.prepend($("").addClass("header-link").attr("href", "#" + id).html("#")); +(function() { + function setJQueryTrigger() { + if (window.$ == undefined) { + setTimeout(setJQueryTrigger, 70); + return; } - }); -}); + + $(function() { + $("#printable").click(function() { + $("body").addClass("printable"); + }); + + return $("h2, h3, h4, h5, h6").each(function(i, el) { + var $el, icon, id; + $el = $(el); + id = $el.attr('id'); + if (id) { + return $el.prepend($("").addClass("header-link").attr("href", "#" + id).html("#")); + } + }); + }); + } + + setJQueryTrigger(); +})(); // @license-end