- 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
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/f9af2663-5f95-4776-a508-11eb9ffcbcf2/facebook_256.gif)
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:
![screen-shot-2014-11-30-at-11.28.58-pm](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/a8b35dc5-69f1-42ce-b4fb-25aa9afbe842/Screen-Shot-2014-11-30-at-11.28.58-PM.png)
Basically, you’re just sending two parameters (u for url, and t for title) to a single url: facebook.com/sharer.php. ::