View Full Version : JSON/Social Media Buttons Lagging up Site

06-27-2012, 07:22 PM

I am making custom social media buttons for a company website, and everything works perfectly fine in the testing stage (pulling page count numbers, having the social buttons scroll with the user and respond with responsive design), but when the code is pushed live, it stops all javascript on the page. Once, it even crashed the site for a few hours.

I'm not sure where the problem might be. I've tried removing bits of my javascript code sections at a time, and narrowed down the cause to this:

/* =============================== Grabbing URL */
url = $(location).attr('href');
beforecounter = " ";
aftercounter = "";

/* =============================== Grabbing Facebook Count */
$.getJSON('http://graph.facebook.com/' + url + '&callback=?',
$('#vert_fbcount').append(beforecounter + data.shares + aftercounter);
$('#horz_fbnum').append(beforecounter + beforecounter + data.shares + aftercounter);

/* =============================== Grabbing Twitter Count */
function(data) {
$('#vert_twitcount').append(beforecounter + data.story.url_count + aftercounter);
$('#horz_twitnum').append(beforecounter + beforecounter + data.story.url_count + aftercounter);

I am not sure if the .getJSON is the problem? It's just surprising since I was able to grab the Facebook and Twitter counts when testing, but when live, all javascript doesn't work and the whole site gets laggy.

Any idea/suggestions on what the problem could be? :confused:

Thank you so much!

- Jeff