- Unsupervised Learning
- Posts
- Implement a Facebook Share Button Using a Single Line of Javascript
Implement a Facebook Share Button Using a Single Line of Javascript
If you’ve messed with getting Facebook buttons on your site you know that there are a couple of ways to do it, but most of them involve using one of their various APIs.
My issue is that I’ve been working on optimizing my site, so I didn’t want to invoke any external scripts at all. So I did a few minutes of research and came up with a way to be able to submit to Facebook–just like their share button–using a single line of Javascript:
Basically, you’re just sending two parameters (u for url, and t for title) to a single url: facebook.com/sharer.php. ::