From 764872d619f9891cbefc2d7803660f9cdaad8442 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 5 Apr 2013 23:44:49 +0200 Subject: [PATCH] Remove social widgets when debugging Social widgets increase load times, add uncontrolled JavaScript code, and open potential security holes. None of these are desirable, especially when debugging. This commit removes the Twitter and Google Plus widgets, at least when the window location has a query string (e.g. "?mode=RAW"). --- resources/social-links.js | 42 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/resources/social-links.js b/resources/social-links.js index 452e73a5ec..80c6809399 100644 --- a/resources/social-links.js +++ b/resources/social-links.js @@ -1,22 +1,26 @@ +if (window.location.search == '') { + + // add tweet buttons + // (adapated from https://twitter.com/about/resources/buttons) + (function() { + var self = document.getElementsByTagName('script')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.async = true; + script.src = '//platform.twitter.com/widgets.js'; + self.parentNode.insertBefore(script, self); + })(); -// add tweet buttons (adapated from https://twitter.com/about/resources/buttons) -(function() { - var self = document.getElementsByTagName('script')[0]; - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.async = true; - script.src = '//platform.twitter.com/widgets.js'; - self.parentNode.insertBefore(script, self); -})(); + // add g+1 buttons + // (adapted from https://developers.google.com/+/web/+1button) + (function() { + var self = document.getElementsByTagName('script')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.async = true; + script.src = 'https://apis.google.com/js/plusone.js'; + self.parentNode.insertBefore(script, self); + })(); - -// add g+1 buttons (adapted from https://developers.google.com/+/web/+1button) -(function() { - var self = document.getElementsByTagName('script')[0]; - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.async = true; - script.src = 'https://apis.google.com/js/plusone.js'; - self.parentNode.insertBefore(script, self); -})(); +}