Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localpcguy/1927926 to your computer and use it in GitHub Desktop.
Save localpcguy/1927926 to your computer and use it in GitHub Desktop.
Async Third party script loader explicit render only (won't render on load of script)
<script>
(function(w, d, s) {
function go() {
var js, fjs = d.getElementsByTagName(s)[0], load =
function(url, id, inTextOption) {
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.src = url; js.id = id;
if (typeof inTextOption !== "undefined" && inTextOption.length) {
try { js.text = inTextOption; } // in try because .text="string" fails in Opera
catch (e) { js.innerText = inTextOption; } // for Opera
}
fjs.parentNode.insertBefore(js, fjs);
};
load('//connect.facebook.net/en_US/all.js#xfbml=0', 'facebook-jssdk');
load('//apis.google.com/js/plusone.js', 'gplus1js', '{"parsetags": "explicit"}');
}
if (w.addEventListener) { w.addEventListener("load", go, false); }
else if (w.attachEvent) { w.attachEvent("onload", go); }
} (window, document, 'script'));
</script>
var sp = {
init: function() {
// Setup event for parsing social icons on ttBlock mouseover
$("#tipHolder").on("mouseover", ".ttBlock", sp.parseSocialIcons);
},
parseSocialIcons: function(e) {
var $this = $(this), el = this;
if (!$this.hasClass("ttBlock")) {
$this = $this.closest(".ttBlock");
el = $this.get(0);
}
if (!$this.find("iframe").length) {
if (typeof gapi !== "undefined") { gapi.plusone.go(el); }
if (typeof FB !== "undefined") { FB.XFBML.parse(el); }
setTimeout(function() { $this.addClass("socialIconsLive"); }, 250);
}
}
}
$(function() {
sp.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment