sapegin's social-likes (old) with removed jquery
Go to file
Vitaliy Filippov 9b78baac95 pass image to vk & mail 2016-05-03 10:14:18 +03:00
contrib v3.0.13 2015-02-16 15:34:11 +03:00
dist pass image to vk & mail 2016-05-03 10:14:18 +03:00
gh-pages Add CNAME. 2016-03-01 09:36:45 +01:00
specs Add test case with unexisting domain and zeroes 2015-11-17 12:54:08 +03:00
src pass image to vk & mail 2016-05-03 10:14:18 +03:00
.gitignore Move the builder page to the main branch. 2016-01-10 19:11:24 +01:00 Changelog and readme. 2016-01-10 19:26:12 +01:00 Tweak readme and contributing guidelines. 2014-04-10 11:01:30 +04:00
Gruntfile.js fix some warnings & update package 2016-05-01 14:41:03 +03:00 Suggest using Social Likes Next. 2016-04-07 08:24:41 +02:00 Fix Markdown. 2016-04-06 16:04:03 +02:00 Tweak license. 2014-04-04 10:20:19 +04:00
package.json fix some warnings & update package 2016-05-01 14:41:03 +03:00

Social Likes

Powered by You

Try the all new Social Likes Next: no jQuery, no counters, Retina, IE11+, improved skins.

Beautiful share buttons with counters for popular social networks: Facebook, Twitter, Google+, Pinterest, Vkontakte, etc. Uses jQuery.

See demo


  • Easy to install.
  • Beautiful and all in one style (with three different skins).
  • Wont explode your pages layout.

Installation and configuration

Use interactive builder to generate the code.

Or install via npm: npm install --save social-likes.

Advanced configuration



All buttons in a row.

<div class="social-likes">
	<div class="facebook" title="Share link on Facebook">Facebook</div>


All buttons in a column.

<div class="social-likes social-likes_vertical">
	<div class="facebook" title="Share link on Facebook">Facebook</div>

Single button

One button with a counter (sum of all the networks). Opens popup with like buttons in vertical layout. Use data-single-title attribute to change button title.

<div class="social-likes social-likes_single" data-single-title="Share me!">
	<div class="facebook" title="Share link on Facebook">Facebook</div>

Icons only

If you want to remove button titles add social-likes_notext class to make it looks better.

<div class="social-likes social-likes_notext">
	<div class="facebook" title="Share link on Facebook"></div>


Options define via HTML data attributes or JavaScript parameters object.


URL of shareable page. Current page by default.


Title for Twitter, Vkontakte and LiveJournal. Current pages title by default.


HTML code for LiveJournal button. By default tag with link to current page.


Disables “likes” counters when “no”. Default: “yes”.


Show counters even when number is 0. Default: “no”.


Share button title for “single button” mode. Default: “Share”.


<div class="social-likes" data-url="" data-title="Landscapists of Russia"></div>
<div class="social-likes social-likes_single" data-single-title="This is Sharing!"></div>
	url: '',
	title: 'Beautiful “like” buttons with counters for popular social networks',
	counters: true,
	singleTitle: 'Share it!'

Services specific options


You can specify via (sites or your own Twitter) and related (any other Twitter you want to advertise) values for <div class="twitter">:

<div class="twitter" data-via="sapegin" data-related="Landscapists">Twitter</div>


You should specify an image URL via data-media attribute on <div class="pinterest">:

<div class="pinterest" data-media="">Pinterest</div>

Manual initialization

Could be useful on dynamic (AJAX) websites.

<div id="share">
	<div class="facebook">Facebook</div>

Dynamic URL changing

You can dynamically replace URL, title and Pinterest image without reinitialization.

<div id="share2" class="social-likes" data-url="" data-title="My example">
	<div class="facebook">Facebook</div>
	url: '',
	title: 'GitHub',
	data: {
		media: ''  // Image for Pinterest button

Refreshing counters

By default counters for any unique URL requested only once. You can force new request with forceUpdate option:

	forceUpdate: true


Triggers for every counter.

$('.social-likes').on('', function(event, service, number) {
	// service: facebook, twitter, etc.

Triggers after all counters loaded.

$('.social-likes').on('', function(event, number) {
	// number is total number of shares

Triggers after popup window opened.

$('.social-likes').on('', function(event, service, win) {
	// win is popup window handler (

Triggers after popup window closed.

$('.social-likes').on('', function(event, service) {
	// Request new counters
	$(event.currentTarget).socialLikes({forceUpdate: true});

	// Or just increase the number
	var counter = $(event.currentTarget).find('.social-likes__counter_' + service);

Adding your own button

You can find some custom buttons in contrib folder.

Define socialLikesButtons object:

var socialLikesButtons = {
	surfingbird: {
		popupUrl: '{url}',
		popupWidth: 650,
		popupHeight: 500

Or with a custom click handler:

var socialLikesButtons = {
	livejournal: {
		click: function(e) {

Add some CSS:

.social-likes__button_surfingbird {
	background: #f2f3f5;
	color: #596e7e;
	border-color: #ced5e2;
.social-likes__icon_surfingbird {
	background: url( no-repeat 2px 3px;

And use it like any other button:

<div class="surfingbird">Surf</div>

See sources (src folder) for available options and class names and contrib folder for custom buttons examples.


Likes or shares?

This plugin allows your users to “share” the content of your website. (Un)fortunately¹ real “likes” are possible only when you use original Facebook, Google+, etc. buttons.

¹ I believe that “shares” are much better and valuable than “likes” because theyre more visible in feed and users could add theyre own comments to links they share. “Like” costs nothing.

How to change title, description and image

You can use Open Graph. It works for Facebook, Twitter, Google+, Pinterest and Vkontakte).

You can add additional Twitter data using Twitter Card. You have to approve every type of Twitter Card.

<meta property="og:type" content="article">
<meta property="og:url" content="{page_url}">
<meta property="og:title" content="{title}">
<meta property="og:description" content="{description}">
<meta property="og:image" content="{image_url}">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@SiteTwitter">
<meta name="twitter:creator" content="@sapegin">

If youre experiencing any problems with meta data try Open Graph Debugger and Twitter Card Validator.

How to fix Twitter counter

Twitter counter API was disabled by Twitter but you can replace it with OpenShareCount. Its free but you have to register your site there.

  1. Create account at OpenShareCount.

  2. Add this script before you include social-likes.js:

var socialLikesButtons = {
  twitter: {
    counterUrl: '{url}&callback=?',
    convertNumber: function(data) {
      return data.count;

How to use Social Likes with Wordpress, etc.

See wiki.

How to track activity with Google Analytics

You can track how many people click on each social button on your site with Google Analytics (or other analytics service). Note that you can track clicks only, not real shares.

$(document).on('', function(event, service) {
    ga('send', 'social', service, 'share', location.href);


The buttons dont work, displayed without design or dont displayed at all

First look at your browsers console. If you see an error “Uncaught ReferenceError: jQuery is not defined”:

Then you need to include jQuery into your page. Make sure you use version at least 1.7 (and lower than 2.0 if you need to support IE8) and you include jQuery before social-likes.js. The easiest way to do it is to use Google CDN:

<script src=""></script>

If you dont see any error check the following:

  1. social-likes.js is included after jQuery and the path is correct.

  2. social-likes_flat.css or social-likes_classic.css or social-likes_birman.css is included in <head> of your page and the path is correct.

So you need your page to look like this:

<!DOCTYPE html>
	<meta charset="utf-8">
	<title>Welcome to my site!</title>
	<link href="social-likes_birman.css" rel="stylesheet">
	<script src=""></script>
	<script src="social-likes.js"></script>

Counters dont work

Twitter counter was disabled in 3.0.15.

In most cases if you dont see counters its because social networks APIs return zeros. You could check API requests results in Network tab in your browsers developer tools:

Double check that you use canonical URLs (without extra parameters such as utm_source). You can change URL via data-url option.

If you have more than one Social Likes blocks on a page with different URLs, Google+ counter will work only for the first block. Google+ counter also wont work when you refresh counters with forceUpdate option or change URL dynamically.

If your site have internationalized domain name (e.g. президент.рф) make sure you convert it to Punycode (e.g. xn--d1abbgf6aiiy.xn--p1ai).

If youre sure that its a bug please file an issue and provide a link to a page with non-working counter.

Release History

The changelog can be found on the Releases page.


Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.



The MIT License, see the included file.