Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Adding all Asynchronous Javascripts to posts and pages
function add_bulk_async_sdk() { ?>
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
add = function(url, id) {
if (doc.getElementById(id)) {return;}
js = doc.createElement(script);
js.src = url;
id &amp;&amp; ( = id);
fjs.parentNode.insertBefore(js, fjs);
// Google Analytics
add(('https:' == location.protocol ? '//ssl' : '//www') + '', 'ga');
// Google+ button
// Facebook SDK
add('//', 'facebook-jssdk');
// Twitter SDK
add('//', 'twitter-wjs');
// Pinterest
}(document, 'script'));
add_action('genesis_before', 'add_bulk_async_sdk');
Copy link

braddalton commented May 27, 2015

Hello Amelia

Shouldn't the file name for the gist be functions.php not genesis-async-php unless you want to load it as a separate file. Got a question about this on the forums

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment