Debugging CSS & JavaScript for AddThis

Most of the support issues I see involve AddThis styles or scripts that are conflicting with the AddThis code. Debugging these sorts of conflicts is pretty easy with the right tools, and these are usually built into every browser. In this post I’ll be using Safari’s Web Developer Tools, but Google Chrome’s Web Inspector or Firebug for Firefox can do similar things.

Debugging CSS Conflicts

Since AddThis code is built from DOM elements, instead of Flash objects or similar non-standard elements, other scripts CSS rules can affect them. This is both a good thing, for instance when you want to center the toolbox, but can be a problem if your stylesheets have overly-broad rules in them. For example, this rule:

<style> a { color:white !important; } </style> 

Will result in something like this:

The counter text is white

It looks like the counter isn’t loaded, but it’s there, and you can see it if you select it:

Like magic!

To debug overly broad CSS rules, control – or right-click – on the element you wish to inspect, then select “Inspect Element”:

Inspect Element Selection

This will take you to a window where you can see all the CSS rules that apply to that element. Search through them to find the one that’s not from AddThis and then click the check box to the left to disable it. You’ll notice that it also gives you the filename and line number of the rule you’re disabling, so you can go straight to that rule in your CSS file and fix it.

Debugging JavaScript Problems

Debugging JavaScript can be a bit more difficult. The first thing to check if AddThis isn’t showing up at all is if the proper variables are set on the page. First, right click anywhere on the page and select “Show Page Source.” Then, type ‘addthis_config’ into the small area at the bottom of the window, next to the blue greater-than sign and then push enter. If the code is set up properly on your page you should see something like this:

addthis_config Output

This will let you check whether your configuration values are correct or if they’re possibly getting overridden by re-declaring the addthis_config variable elsewhere on the page. Other good ones to check are addthis_share, which lets you check the sharing configuration, and just addthis, which will verify that our code is being loaded properly.

Another problem I see a lot is errors in other JavaScript on the page causing the buttons not to render. AddThis buttons are rendered, or put on the page, using JavaScript. If there is an error in other JavaScript on the page that halts the execution of scripts on the page then our buttons won’t show up:

They're not there

This page has an onload attribute in the body that isn’t a valid function:

<body onload="AFunctionThatDoesntExist()"> 

To find out where this error is, right-click on the page and select “Show Page Source” again. Then, select the error icon in the upper left corner of the Developer Tools window. (You may have to display the window’s left sidebar to see it.)

Onload Error Window

Now that we know what the problem is, we can fix it. In this case, all we have to do is define a function named AFunctionThatDoesntExist, like this:

<script type="text/javascript"> function AFunctionThatDoesntExist(){ var docBody = document.getElementsByTagName('body'); var mySubheading = document.createElement('h2'); var myText = document.createTextNode('That function does exist!'); mySubheading.appendChild(myText); docBody[0].appendChild(mySubheading); } </script> 

Then the AddThis buttons will show up after the function runs:

AddThis displaying after the function appends text to the document

Debugging Bigger Problems

Note: This is for advanced users who don’t mind editing HTML or using a command line

Sometimes you’re not sure what file has the CSS or JavaScript conflict in it. In these case you’ll have to disable the CSS and/or JavaScript on the page until you get the buttons to work, then figure out what conflicts are occurring.

Here’s how I’d do it on a Mac, but the steps are similar for a PC. First, get a web server. For Mac users this is built in. Just go into the Sharing preference pane in System Preferences and check “Web Sharing.”

Then, open up the Terminal app in your Applications folder, which will give you something like this:

A Terminal Window

At the prompt, type this command (without the dollar sign.)

$ curl http://www.example.com/ > Sites/example.html 

(Replace http://www.example.com/ with the URL of the page you want to debug.) This will download the source of the page to your Sites folder in a file example.html. Open this file in a text editor and add the following just after the <head> tag:

<base href="http://www.example.com/"/> 

(Again, replace http://www.example.com with the URL of the page you’re debugging.) Now open your browser and go to: http://localhost/~[user]/example.html where [user] is replaced with your username. Your page should show up with all the images and scripts.

Example page from my local server

Once you’ve got that, edit the page in the same text editor to start removing JavaScript and CSS, refreshing the page after each edit to see if it fixed the issue. Once you find the AddThis buttons behaving like you should, replace all but the last item you removed to see if that’s the culprit.

Once you’ve found the culprit it’s up to you to decide whether to keep using it, upgrade to a newer version that might not have a bug (if it’s a third-party library), or contact us to see if we have a workaround. Please note that we don’t support any external JavaScript beyond helping you find out that there’s a problem.

Looking for errors like this before you contact our support team might help you save time and frustration when AddThis is acting up.

October Hackathon 2012: Robotics for the Remote Worker and Plenty of Plants

Another successful AddThis Hackathon is in the books! We measure the success of a Hackathon in a few different ways:

For those not familiar with hackathons, they are our 24-hour sprints of innovation. A-Teamers group up, or work alone, on a new project outside of what they are currently working on in their day-to-day. The energy surrounding a hackathon is always fun and familial. They are a very important part of the AddThis culture.

WINNER: Telepresence Roomba Robot

The winning project of this installment of all-night coding was quite impressive. The team went out to solve a common challenge we face at AddThis. Since we have multiple offices across the country, sometimes communicating and collaborating requires extra effort. So, the team created a telepresence robot using a Roomba, a MacBook Air, foamcore and a rocket launcher. And the entire thing was controlled from a Google Hangout! See it in action:

Congratulations to the winning team! It was well deserved.

Honorable Mention: AddThis Garden

The unofficial “runners-up” also deserve Earth Day Award 2012. “AddThis Plant” went on a mission to “green” our new HQ office in Virginia. It is an extensive project of plant growing, caring and loving with the end goal to have a nice array of beautiful oxygen-producing decorations for our work space. Check them out:

And those are just the official winners! There were many other brilliant and noteworthy projects that did not go unnoticed or under-appreciated. Some of which will be used to make everyday AddThis processes more efficient — a win all by itself!

Like this? Check out more posts about AddThis Engineering.

 

Service Outage

We had a network outage for several hours yesterday afternoon (US time).  Our buttons continued to serve into web pages but sharing was down and our website, analytics, and web services were unavailable.  We truly apologize for the outage.  We want to be a critical part of your social infrastructure and we can’t keep your trust unless our service is always available.  We take this responsibility very seriously.  The root cause was an administrative error by one of our service providers and we’ve made changes to reduce the risk of further network outages.

PennApps 2012 Wrapup

Sunrise at PennApps
6:33am Sunday: the sun rises on the final day of PennApps

This past weekend Matt Keesan and I traveled down to Philadelphia for PennApps, America’s largest student-run hackathon. 48 hours, 91 teams, 320 hackers, $10K+ in prizes–any way you look at it, the event was huge. So before getting into some of our favorite hacks of the weekend, congratulations to the whole PennApps team, including frontman Pulak Mittal, for keeping the wifi, food, and energy flowing all weekend. AddThis was a proud sponsor and we’re looking forward to next semester!

Vivek Panyam, Facebook for Grandma

Vivek Panyam with his AddThis-infused Facebook for Grandma app
Advice for solo-hackers-to-be: Vivek worked in high-traffic areas of the hackathon and was accordingly flush with advice and attention from the 40 sponsors at the event. What’s more, he took the advice seriously.

Solo-hacker and UPenn freshman Vivek Panyam won the “most delicious UI” award for Facebook for Grandma, a pared-down Facebook app offering a compelling subset of features in an even more compelling package. Seriously, your grandmother just got 30 clicks closer to your photos; you’ve been warned.

Devon Peticulas and Dan Mundy, bbcat

PennApps veterans Devon Peticulas and Dan Mundy won big style points for scoping out and executing on a deceptively simple tamagotchi-inspired pet. Get your own at bbcat.co, then share it with your significant other to either test his or prove your own commitment. What impressed me most about the duo is that at the 11th-hour, when most teams were tracing syntax errors, Devon and Dan were sitting pretty, chatting about node.js design patterns and that perfect shade of beige found on the Atari 800. What’s more, they are coordinating HackRU at Rutgers next month. Maybe they’ll throw us dog-lovers a bone.

Devon Peticulas of team bbCat models AddThis shades
Devon Peticulas wears AddThis sunglasses at night. And a Venmo t-shirt for three consecutive days.

Raj, Dave, and Shiva: BuddyHack, BuddyMeme

Were there an award for the most roguish team at PennApps, the entire UMich contingent would have had to split it. Instead, we gave our own “Most Viral” award to BuddyHack, the only project that was developed, deployed, HackerNews’d, and banned before the demos even began! Luckily the team is prolific and their BuddyMeme project is still up from the Michigan Facebook Hackathon held this March. By creating a dead-simple meme generator (open-sourced, by the way) and leveraging the tight-knit nature of Facebook’s network, BuddyMeme allows memes to thrive within small social groups.

My humble self with the BuddyHack crew
I can has internship? Me and the BuddyHack team.

There were too many cool projects for me to list. AddThis was super happy to share the weekend with so many talented developers.

PennApps 2012

Joe Sullivan and I are headed down to Philadelphia today for Penn Apps 2012, an awesome bi-annual 48-hour hackathon for university students, run by Penn students themselves. There’s thousands of dollars in prizes, not to mention mentors from sponsors like us, Facebook, Google, Dropbox, Mongo, Mozilla, the New York Times, Quora, Zappos, and more. They’ll even reimburse your bus fare (which is extra rad since the price of a ticket from New York has risen substantially from the $5 I paid as an undergrad).

This session is already completely full, but there’s a waiting list for student hackers, and the next PennApps is just six months away. (All developers in the area are invited to come by to help advise teams in their areas of expertise.)

If you’re a student looking for help, or live in Philly and just want to meet your friendly local AddThis developers, please drop me a line or send a tweet (@itsjoesullivan or @keesan)! We’re excited to be sponsoring our first university hackathon.

Introducing Our Newest Sharing Experience

We’re happy to announce major updates to the AddThis sharing tool suite: the new design we’ve been testing in AddThis Labs graduates today, with a slew of new features. Go grab the new code!

We’ve written before about the mind-boggling amount of data every day, and how we use it to provide insights both to our publishers and into trends across our network. But we also use data to drive and refine our own processes and designs. Today, we’ve used what we’ve learned to make sharing even easier, and more personal. That means more engagement from your visitors, more sharing, and more traffic for your site.


Simpler design.

First, we have a new look. We’ve streamlined and simplified the compact menu. We’ve made our email form a lot easier to use, like the email clients you’re already familiar with. Our expanded menu’s been optimized for faster sharing to the most popular services in your region, and easier searching for your personal favorites. (As always, we’ll highlight the services you use for even easier sharing next time.) We’ll take advantage of jQuery on pages that already include it for simple but lovely transitions. And while our new platform takes advantage of HTML5 and loads of modern browser features, we won’t leave you out in the cold if you’re stuck on IE6–though, seriously guys, it’s time.

In Labs, the updated design increased sharing by 11%. In production, it’s going to do even better–due to our second major update.

Instant sharing.

Sharing to Facebook or Twitter used to mean popping a new window. That’s fast, but we figured if we made it even faster, more people would be sharing your content. To that end, we’re introducing “instant” inline sharing to the most popular social networks. If your users link their social accounts with AddThis, they’ll be able to share directly to Facebook or Twitter without even leaving your page. The new inline interface means there’s no extra page load–that means more unimpeded sharing. Even better, once a user authenticates, they’ll remain logged in on every single site with AddThis, until they log out. Everybody wins.

Adding social sign in to our sharing tools doesn’t just mean it’s easier to share. It also means it’s a lot easier to personalize your AddThis experience–easily choose the services you want to see once, and you’ll see them across all the sites that use AddThis.

Pain-free pinning.

Our recent updates for Pinterest are fully integrated with the new design. We’ve created the simplest and easiest way to integrate with Pinterest: almost no work necessary! Put AddThis on any page you want to make pinnable, and we’ll show a simple, elegant lightbox to showcase all the images on your page for your users to pick from. You can always specify your own image, too, if you want! We’ve found this feature can boost sharing to Pinterest by 20% or more.

You can add all these capabilities to your site with one simple code snippet. Take a look and try it out!

Our plugins for WordPress, Magento, and Shopify will be updated this week to support the new surfaces.

Questions? Comments? As always, we’d love your feedback.

Introducing Social Sign In

We’re stoked to announce the newest addition to AddThis Labs:
Social Sign In.

You’ve probably noticed that many websites now allow you to register or sign in using one of your existing social network accounts, like your Facebook username or your Twitter ID. It’s not just a startup fad; in fact, there’s solid science behind it. Blue Research studied the holiday shopping habits of US consumers and noticed that the vast majority of us are annoyed by having to create a new account to use a site, and would generally rather use one of our existing social network accounts.

If you’ve ever had to register on an obscure website just to buy one perfect gift, you probably know exactly how this feels! Even outside of retail applications, users are much more likely to register for and engage with your site if the process is bootstrapped with their existing online identity–some research has shown users authenticating socially spend up to 50% more time on site than the rest.

Seeing the value of social authentication is easy. Building it, though, hasn’t been. Most existing social authentication solutions have either required a lot of complicated server-side programming; mastering the ins and outs of OpenID, OAuth, and other specifications; or paying for a hosted solution and thus giving up control over your users’ data, not to mention some of your budget!

Our approach is simpler. And it might be the right one for you.

Example of Google, Twitter and Facebook sign in buttons
Use their standard buttons, or design your own.

Social Sign In by AddThis is a straightforward JavaScript library that makes it easy to strengthen your relationship to your users by adding Facebook, Twitter or Google authentication to your site.You provide the application keys for each service you’d like to integrate. We take care of rendering the buttons and managing the authentication flow. When a user successfully authenticates, we provide the data directly to you, via JavaScript.


Some of the social data you’d get,
if I logged into your site using Social Sign In.

From then on, it’s your show, whether you want to pre-fill a registration form, directly create a new account, or store the data for later analysis. Our goal is just to make it easy to bring your users’ social data to your site, whether for registration, authentication, or personalization. You can try it out live on our Labs page.

Want to offer as many services as possible? No problem. Regardless of the network used, the data comes back in the same format — so you only have to write code once.

Like all our tools, you’ll get data in our analytics dashboard, too. We’re starting by keeping track of what networks your users are logging in with, but we’d love your thoughts on other information that might be relevant.

To make integration even easier, we’ve open sourced a fully functional demo in JavaScript, PHP and MySQL, with a simple user registration system based on Social Sign In. If you’ve always wanted a user system, feel free to start with ours! Or you can use our code as a basis for integrating Social Sign In into your existing registration and authentication system.

Questions? Comments? We’d love your feedback!

Pride, Glory and Scotch: A Wrap-Up of Hackathon Summer 2012

Innovation, collaboration … sleep deprivation. Put all those together and you know that AddThis Hackathon Summer 2012 was a great success!

Over a dozen amazing presentations were given this morning from individuals and teams, showing off some of the most impressive projects to date! Fun new products, feature overhauls and internal tools for improved efficiency – our talented crew covered all the bases.

While the grand prize — a fancy bottle of scotch, some gift certificates, and bragging rights until the next hackathon — could only go to one project, every participant is a winner in teamwork, creativity and dedication.

We’ll be sharing more information about the various projects as we roll some of them out in the coming months but to give you an idea, topics and tools ranged from new Pinterest solutions for publishers to usage of gestural and voice control technology. It was an impressive array of presentations and they made one thing very clear: the A-Team is proving that the future is now!

Here is a look back at the past 24 hours. Now excuse us while we go catch some Zzz’s!

The winners with their most important prize.

Shhh! Sleepy hackers! ...

Cats hacking?! Only at AddThis.

Hungry, hungry hackers enjoying our early morning omelete bar!

If this looks like fun to you, check out our careers page. We’re hiring hackers and other great minds to join the party!

AddThis Hackathon Summer 2012 is Underway!

Coders crack your fingers, on your keyboards, ready, set, GO! It’s Hackathon time — one of our favorite pastimes here at AddThis.

What is a Hackathon exactly? Hackathons are our 24-hour full-team sprints of innovation.  Individuals can work alone or as part of teams. The only real rules are:

  1. The projects have to have something loosely to do with AddThis.
  2. They should be compelling.
  3. And finally, they must be built and demoed within 24 hours!

Not only are Hackathons a great way to reinforce the importance of teamwork, but some amazing products and tools have been born out of the tradition.

Keep checking in on our Twitter account, where we’ll be live tweeting photos and other fun  behind-the-scenes Hackathon action! Here are some early snapshots:

Look at all that collaboration! We love it!

Big Data Part III: A Simple Decision – Performance, Predictability, Price

This is the last in a three part series on the processing and infrastructure of AddThis. Make sure to check out part one and part two.

In the end, our decisions rest on cost and control.  For our uses, CPU cycles in the cloud are about 3x more expensive than the fully loaded cost of dedicated cycles in our own data center.  Data stored in the cloud is at least 10x more expensive than in our own clusters.  Even if data storage were free, we would still be paying for CPU cycles to process the data and network costs to expose it.  But the killer is still latency and IO bottlenecks.  At our scale, there aren’t meaningful pricing options to overcome these in the cloud.

As both our business and cloud offerings have matured, we would still make the same choices around internal build-out vs shared cloud.  If there is one reason that drives this decision, it’s the fact that we have a business in which our needs can be modeled and anticipated.  And with the ability to predict comes the ability to optimize resources for both cost and performance.  With our own build-outs, we are able to regain control and apply it to the bottom line.  But to achieve this goodness requires a clear understanding of your needs, a skilled dev/ops team, a hacker mentality and focus.

  • clouds remain king for spot capacity, typical web apps, development
  • they do not solve complex management problems or magically scale apps
  • operations at even modest scale still requires skilled, creative staff
  • once a baseline of capacity is known, dedicated hardware can’t be beat

Depending on the profile of your business, cloud computing could be a game changer.  Our decision to bypass the traditional cloud was game changing for us;  we are noticeably stronger, faster and larger than our competitive set.  And with our developed abilities in large scale data and processing, we are in control of our destiny, ready for what comes next.

If you have any questions or want to hear more about our data processing capabilities, please feel free to reach out to us.