Better twitter script loading

This commit is contained in:
L. Bradley LaBoon 2016-06-16 20:13:57 -04:00
parent f8a08c3f08
commit d390fc651d
3 changed files with 18 additions and 1 deletions

View File

@ -10,6 +10,5 @@
<code>CF30 A41A 0698 6B1F 6037 208A 3D21 FA83 9D9A 229F</code><br />
Public key: <a target="_blank" href="http://pgp.mit.edu/pks/lookup?op=get&search=0x3D21FA839D9A229F">9D9A229F</a>
<a class="twitter-timeline" data-dnt="true" href="https://twitter.com/BradLaBoon" data-widget-id="716765398503395329">Tweets by @BradLaBoon</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");document.getElementById("twitter-widget-0").style.marginTop="10px";</script>
</nav>
<!--End navbar-->

View File

@ -9,6 +9,7 @@
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="index.css" />
<script type="text/javascript" src="js/navbar.js"></script>
<script type="test/javascript" src="js/twitter.js"></script>
</head>
<body>
<div id="wrapper">

17
js/twitter.js Normal file
View File

@ -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);
})();