Social sharing buttons without JavaScript
Most social sharing widgets load third-party JavaScript for something a normal link can do. If page weight and privacy matter, link directly to each service’s sharing URL and style the anchor like a button.
Replace the uppercase placeholders with URL-encoded values from the current page. Encoding matters when a title or URL contains spaces, ampersands, or other reserved characters.
<a href="https://twitter.com/intent/tweet?url=YOUR-URL&text=YOUR-TITLE&via=YOUR-TWITTERHANDLE">Twitter</a>
<a href="https://facebook.com/sharer/sharer.php?u=YOUR-URL">Facebook</a>
<a href="http://www.linkedin.com/shareArticle?mini=true&url=YOUR-URL&title=YOUR-TITLE&summary=YOUR-SUMMARY">LinkedIn</a>
<a href="http://pinterest.com/pin/create/button/?url=YOUR-URL&media=YOUR-IMAGE-URL&description=YOUR-DESCRIPTION">Pinterest</a>
<a href="http://www.reddit.com/submit?url=YOUR-URL&title=YOUR-TITLE" target="_blank" title="Share on Reddit">Reddit</a>
Pinboard
<a href="https://pinboard.in/popup_login/?url=YOUR-URL&title=YOUR-TITLE" target="_blank" title="Share on Pinboard">Pinboard</a>
<a href="mailto:?subject=SUBJECT&body=:BODY" target="_blank" title="Email">E-mail</a>
VKontakte
<a href="https://vk.com/share.php?url=YOUR-URL" target="_blank">VK</a>
These links avoid third-party scripts, but clicking one still sends the visitor to that service. I would include only the networks the site’s readers actually use; a long row of every possible button quickly becomes clutter.
Enjoyed reading this?
If you found this article helpful, consider supporting my writing. Every little bit helps keep this blog going.
Related articles
- Keeping a Website Usable When JavaScript Fails
Build content, navigation, and forms on working HTML so one failed script removes an enhancement instead of the whole page.
- How Much JavaScript Does a Website Really Need?
Start with the page's job, use the browser's native features, and add JavaScript only where its behaviour justifies the cost.
- Building a modal with HTML dialog
Build modal windows from the native HTML dialog element, including backdrops, forms, Escape handling, and practical examples.