Skip to content

Instantly share code, notes, and snippets.

@dalevross
Last active November 11, 2019 07:38
Show Gist options
  • Save dalevross/b848057b33fbea82d80aedc8460cd0b3 to your computer and use it in GitHub Desktop.
Save dalevross/b848057b33fbea82d80aedc8460cd0b3 to your computer and use it in GitHub Desktop.
Code I used to create twitter follow buttons from profile links
//Add the twitter-follow-button class to all anchors that contain twitter
//The selector could be tweaked to be more specific.
$("a[href*=twitter]").addClass("twitter-follow-button");
//Add the twitter API code dynamically
! function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment