From d390fc651d26607ea3298e05158944774ff4b856 Mon Sep 17 00:00:00 2001 From: "L. Bradley LaBoon" Date: Thu, 16 Jun 2016 20:13:57 -0400 Subject: [PATCH] Better twitter script loading --- include/navbar.html | 1 - index.shtml | 1 + js/twitter.js | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 js/twitter.js diff --git a/include/navbar.html b/include/navbar.html index 1edcf23..6ab42f9 100644 --- a/include/navbar.html +++ b/include/navbar.html @@ -10,6 +10,5 @@ CF30 A41A 0698 6B1F 6037 208A 3D21 FA83 9D9A 229F
Public key: 9D9A229F Tweets by @BradLaBoon - diff --git a/index.shtml b/index.shtml index 50e4171..5e72d7c 100644 --- a/index.shtml +++ b/index.shtml @@ -9,6 +9,7 @@ +
diff --git a/js/twitter.js b/js/twitter.js new file mode 100644 index 0000000..61ddb77 --- /dev/null +++ b/js/twitter.js @@ -0,0 +1,17 @@ +(function() { + var loadTwitterFeed = function() { + if (!document.getElementById("twitter-wjs")) { + var fjs = document.getElementsByTagName("script")[0]; + var js = document.createElement("script"); + js.id = "twitter-wjs"; + js.src = "//platform.twitter.com/widgets.js"; + fjs.parentNode.insertBefore(js, fjs); + } + }; + + // Attach onload handler + if (window.addEventListener) + window.addEventListener("load", loadTwitterFeed, false); + else if (window.attachEvent) + window.attachEvent("onload", loadTwitterFeed); +})();