Add Lazy Loading Social Sharing Buttons to your WordPress Blog

Add Lazy Loading Social Sharing Buttons to your WordPress Blog

Tutorial Details
  • Program: WordPress, Socialite.js
  • Difficulty: Beginner Level
  • Estimated Completion Time: 15 mins

One of the most common and important parts of every blog is a collection of social media buttons i.e. Facebook’s Like button, Twitter’s tweet button, Google’s +1 button etc. Each social platform adds a JavaScript file with its buttons, this means when a blog page loads it has to wait for the 300kb of social media. This hangs the rendering of the page which results in increased page load time. To resolve this issue some of the really big blogs have devised certain techniques through which the social media buttons can be loaded asynchronously. In this tutorial you will learn how to add this “lazy loading” social sharing buttons to your WordPress blog.


Introduction:

These icons will be using a JavaScript library made by . .Net magazine published the Big question: should we drop social media buttons? with opinions and anecdotes from various professionals. This inspired him to reply to them with a nice handy code snippet.

Social widgets are massive. They’re effectively additional websites sand-boxed within tiny iframes and most are poorly optimized. Facebook’s “like” button is appalling. This problem cannot be understated and I developed Socialite.js for exactly that reason. Socialite defers loading and works extremely well. It doesn’t reduce the amount of bytes being shipped, but it does let your website load first before the stream is saturated with social extras.
- David


Some Words About Socialite

Socialite provides a very easy way to implement and activate a plethora of social sharing buttons — any time you wish. On document load, on article hover, on any event!

If you’re selling your soul, you may as well do it asynchronously.
- David

Features and Benefits

  • No dependencies to use.
  • Loads external resources only when needed.
  • Less than 5kb when minified and compressed.
  • More accessible and styleable defaults/fallbacks.
  • Support for Twitter, Google+, Facebook, LinkedIn, Pinterest, and Spotify.
  • Extensible with other social networks.
  • Mimics native implementation when activated.
  • Supported in all browsers (providing the buttons are).

Step 1 Uploading the JavaScript

Let’s roll. First step is to upload the socialite.min.js file, which I recommend you load in your footer. Download the package from socialitejs.com, open it, and upload the socialite.min.js file to your wp-content/themes/your-theme-folder/js/ folder (if the js folder doesn’t exist, create it first).


Step 2 Adding the Script to the Footer

Add Socialite

After uploading the JS file to your theme’s folder, add the following code into your theme’s functions.php file.

function wptuts_load_socialite() {

	// Register Socialite
	wp_register_script( 'socialite', get_template_directory_uri() . '/js/socialite.min.js', array(), '', true );

	// Now enqueue Socialite
	wp_enqueue_script( 'socialite' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_load_socialite' );

Initialize Socialite

Now create a new JS file in your wp-content/themes/your-theme-folder/js/ folder called wptuts-social.js and put the following code in it.

jQuery(document).ready(function($) {
	$('.social-buttons').one('mouseenter', function() {
		Socialite.load($(this)[0]);
	});
});

Now we have a second JS file, we need to amend the PHP code we added to our functions.php file, so it should now look like the following.

function wptuts_load_socialite() {

	// Register Socialite
	wp_register_script( 'socialite', get_template_directory_uri() . '/js/socialite.min.js', array(), '', true );
	// Register social initialiser script
	wp_register_script( 'wptuts-social', get_template_directory_uri() . '/js/wptuts-social.js', array('jquery', 'socialite'), '', true );

	// Now enqueue Socialite
	wp_enqueue_script( 'wptuts-social' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_load_socialite' );

What Is This Code?

In the first step you uploaded socialite.min.js to your theme’s folder, after that in the second step you included that script in your theme’s footer. Then you added a little code to trigger the social button on the mouseenter property for a specific class i.e. the class of our social buttons is social-buttons, when the mouse enters into that class or you could say when someone hovers the mouse over the social-buttons class, the social sharing buttons will load right at that moment.

In the code above this line is responsible for triggering the social buttons, you can change its class (i.e. social-buttons) to any other you want.

	$('.social-buttons').one('mouseenter', function() {

Step 3 Adding the CSS

We will discuss where to add the HTML later, let’s add the CSS first. So, we are about to add the CSS which will hide the button’s text and will show an image in place of them when they are not loaded. You are free to modify the CSS to suit your theme, that way it will make you stand out from others. David has coded the following CSS.

Create a new CSS file called wptuts-social.css in your wp-content/themes/your-theme-folder/css/ folder (if the css folder doesn’t exist, create it first).

Then add the following code into the file.

/*
 * Socialite Look-a-like defaults
 */

.social-buttons { display: block; list-style: none; padding: 0; margin: 20px; }
.social-buttons > li { display: block; margin: 0; padding: 10px; float: left; }
.social-buttons .socialite { display: block; position: relative; background: url('https://tuts-authors.s3.amazonaws.com/wp.tutsplus.com/AhmadAwais/2012/08/29/social-sprite.png') 0 0 no-repeat; }
.social-buttons .socialite-loaded { background: none !important; }

.social-buttons .twitter-share { width: 55px; height: 65px; background-position: 0 0; }
.social-buttons .googleplus-one { width: 50px; height: 65px; background-position: -75px 0; }
.social-buttons .facebook-like { width: 50px; height: 65px; background-position: -145px 0; }
.social-buttons .linkedin-share { width: 60px; height: 65px; background-position: -215px 0; }

.vhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }

Now let’s go back and modify the PHP code we put into our functions.php file again to load the new CSS file, as follows.

function wptuts_load_socialite() {

	// Register Socialite
	wp_register_script( 'socialite', get_template_directory_uri() . '/js/socialite.min.js', array(), '', true );
	// Register social initialiser script
	wp_register_script( 'wptuts-social', get_template_directory_uri() . '/js/wptuts-social.js', array('jquery', 'socialite'), '', true );

	// Now enqueue Socialite
	wp_enqueue_script( 'wptuts-social' );

	// Register social CSS
	wp_register_style( 'wptuts-social', get_template_directory_uri() . '/css/wptuts-social.css');

	// Now enqueue social
	wp_enqueue_style( 'wptuts-social' );
}
add_action( 'wp_enqueue_scripts', 'wptuts_load_socialite' );

Point to Ponder

Make sure you change the sprite image path to your own server. You can download the image below and upload it to your blog and then swap its location at line #7 in the above CSS code.


Step 4 HTML Markup

Let’s see the HTML code for these buttons

<ul class="social-buttons cf">
	<li><a class="socialite twitter-share" href="http://twitter.com/share" rel="nofollow" target="_blank" data-text="<?php the_title() ?>" data-url="<?php the_permalink() ?>" data-count="vertical" data-via="twitter-username-here"><span class="vhidden">Share on Twitter</span></a></li>
	<li><a class="socialite googleplus-one" href="https://plus.google.com/share?url=http://socialitejs.com" rel="nofollow" target="_blank" data-size="tall" data-href="<?php the_permalink() ?>"><span class="vhidden">Share on Google+</span></a></li>
	<li><a class="socialite facebook-like" href="https://www.facebook.com/sharer.php?u=https://www.socialitejs.com&t=Socialite.js" rel="nofollow" target="_blank" data-href="<?php the_permalink() ?>" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false"><span class="vhidden">Share on Facebook</span></a></li>
	<li><a class="socialite linkedin-share" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink() ?>&title=<?php the_title() ?>" rel="nofollow" target="_blank" data-url="<?php the_permalink() ?>" data-counter="top"><span class="vhidden">Share on LinkedIn</span></a></li>
</ul>

Things to do here:

  • Change twitter-username-here with your own Twitter username in the code above.

Where to Add This Code?

This code can be added to a lot of places by a lot of methods. Let me give you some examples

You can add this code:

  1. Below the post meta in your single.php
  2. Below the content in your single.php
  3. In your index.php inside the loop etc.

Step 5 Adding HTML to WordPress

Manual Method

Go to your wp-content/themes/your-theme-folder/ folder, and open your single.php file. Then find the_content, and you will find some code like this <?php the_content() ?>. Add the HTML code shown next below it or above it.

Adding Before a Post

Go to your wp-content/themes/your-theme-folder/ folder, and open your functions.php file. Add the below code at its end:

function social_before_the_content( $content ) {
	$custom_content = '
<ul class="social-buttons cf">
	<li><a class="socialite twitter-share" href="http://twitter.com/share" rel="nofollow" target="_blank" data-text="<?php the_title() ?>" data-url="<?php the_permalink() ?>" data-count="vertical" data-via="twitter-username-here"><span class="vhidden">Share on Twitter</span></a></li>
	<li><a class="socialite googleplus-one" href="https://plus.google.com/share?url=http://socialitejs.com" rel="nofollow" target="_blank" data-size="tall" data-href="<?php the_permalink() ?>"><span class="vhidden">Share on Google+</span></a></li>
	<li><a class="socialite facebook-like" href="https://www.facebook.com/sharer.php?u=https://www.socialitejs.com&t=Socialite.js" rel="nofollow" target="_blank" data-href="<?php the_permalink() ?>" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false"><span class="vhidden">Share on Facebook</span></a></li>
	<li><a class="socialite linkedin-share" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink() ?>&title=<?php the_title() ?>" rel="nofollow" target="_blank" data-url="<?php the_permalink() ?>" data-counter="top"><span class="vhidden">Share on LinkedIn</span></a></li>
</ul>
';
	$custom_content .= $content;
	return $custom_content;
}
add_filter( 'the_content', 'social_before_the_content' );

Adding After a Post

Again Go to your wp-content/themes/your-theme-folder/ folder, and open your functions.php file. Add the below code at its end:

function social_after_the_content( $content ) {
	$custom_content .= $content;
	$custom_content .= '
<ul class="social-buttons cf">
	<li><a class="socialite twitter-share" href="http://twitter.com/share" rel="nofollow" target="_blank" data-text="<?php the_title() ?>" data-url="<?php the_permalink() ?>" data-count="vertical" data-via="twitter-username-here"><span class="vhidden">Share on Twitter</span></a></li>
	<li><a class="socialite googleplus-one" href="https://plus.google.com/share?url=http://socialitejs.com" rel="nofollow" target="_blank" data-size="tall" data-href="<?php the_permalink() ?>"><span class="vhidden">Share on Google+</span></a></li>
	<li><a class="socialite facebook-like" href="https://www.facebook.com/sharer.php?u=https://www.socialitejs.com&t=Socialite.js" rel="nofollow" target="_blank" data-href="<?php the_permalink() ?>" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false"><span class="vhidden">Share on Facebook</span></a></li>
	<li><a class="socialite linkedin-share" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink() ?>&title=<?php the_title() ?>" rel="nofollow" target="_blank" data-url="<?php the_permalink() ?>" data-counter="top"><span class="vhidden">Share on LinkedIn</span></a></li>
</ul>
';

	return $custom_content;
}
add_filter( 'the_content', 'social_after_the_content' );

Screenshots

Let’s take a look at these lazy loading social sharing buttons:

Before Hover

This is how the social icons look when the page first loads

before hover

After Hover

When you hover over them, the buttons load their files to become like shown below

after hover

Final Words

Tip: Be creative, don’t just copy / paste the code above and put it on your blog, try to give it a new look. Let the creative juices flow!

Some Examples

How Do I Use Them?

You can see the image below from my blog, how I use them. (Inspired by Mashable) (Live View)

Freakify.com | Learn How to Blog Like a Pro
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://ericrasch.com Eric Rasch

    Great writeup! I’ve been using Socialite on my last two projects in a very similar method. I like the extra details you added about the before/after Post functions.

    • http://freakify.com Ahmad Awais
      Author

      Thanks for liking the tutorial Eric!

  • http://www.bazish.net bazish

    I always go for the code snippets where i can kill Plugins from my WordPress theme, your tutorial definately give me power to kill one of the social sharing plugins and also help it to lazy load.

    few things to discuss…

    In step 2, Under Initialize Socialite, can’t see JQuery script for linkedin..
    is it required or not?

    Also is there a typo error on the same step for googleplus JQuery part.?
    JQuery(‘.googlepluss’).sharrre({

    thanks for the good tutorial… i bookmarked it and will give it try first time in the morning.

    • http://freakify.com Ahmad Awais
      Author

      Well, that really is a typo :) I have mailed Japh he will take care of it.
      Whereas, the code in Step 2 can be more optimized I have made it more general, all you have to do now, is to add a js file in footer with following code in it.

      
      $(document).ready(function()
       {
      
        $('.social-buttons').one('mouseenter', function()
        {
         Socialite.load($(this)[0]);
        });
      
       });
      
  • Claudio Sanches

    Hi.

    What is .share() or .sharrre()?

    • http://freakify.com Ahmad Awais
      Author

      Those were the functions with spell mistakes in them.
      Well, that really is a typo :) I have mailed Japh he will take care of it.
      For now, the code in Step 2 can be more optimized I have made it more general, all you have to do now, is to add a js file in footer with following code in it.

      
      $(document).ready(function()
       {
      
        $('.social-buttons').one('mouseenter', function()
        {
         Socialite.load($(this)[0]);
        });
      
       });
      
      • Claudio Sanches

        On WordPress the right would be:

        jQuery(document).ready(function($)
        {

        $(‘.social-buttons’).one(‘mouseenter’, function()
        {
        Socialite.load($(this)[0]);
        });

        });

        Avoiding conflict…

        • http://wp.envato.com/ Japh Thomson
          Staff

          Quite right, Claudio! Which is actually how it is in the article.

  • http://techgyo.com Sreejesh

    Nice tutorial Ahmed, can you also share how to make the buttons appear fixed after title section, like you have in your website.

    • http://freakify.com Ahmad Awais
      Author

      I am writing another tutorial for it :)
      It is something completely different from this one.

      • http://techgyo.com Sreejesh

        Thanks, is it going to be published on your blog or here?

  • Jeff

    Great tutorial! I was having trouble with the wordpress plugin using custom post types but this gives me a better level of control.

    I did see a typo that was giving me some trouble:

    function wptuts_load_socialiate() {

    Of course it needs to be function wptuts_load_socialite() {

    Thanks.

    • http://freakify.com/ Ahmad Awais
      Author

      Well, Japh will take care of it.

      • http://wp.envato.com/ Japh Thomson
        Staff

        All fixed! Thanks :D

  • Joost

    Great tutorial.

    Is it also possible to use a screenshot of my current social media buttons together, and place that one image over all the social buttons, so that it will disappear on mouse over?

    • http://freakify.com Ahmad Awais
      Author

      Thanks,
      Yes just swap the image link in the CSS code with the link of your screenshot.

  • tpk

    Hi, very useful tut !
    However, in the html snippets “Adding before and after the post” shouldn’t be the u & t parameters of the facebook the_permalink() and the_title() respectively?

    • http://freakify.com Ahmad Awais
      Author

      The article will be updated soner than later. I think I forgot to replace them. Till then use the below html in every part.

      <ul class="social-buttons cf">
          <li><a class="socialite twitter-share" href="http://twitter.com/share&quot; rel="nofollow" target="_blank" data-text="<?php the_title() ?>" data-url="<?php the_permalink() ?>" data-count="vertical" data-via="twitter-username-here"><span class="vhidden">Share on Twitter</span></a></li>
          <li><a class="socialite googleplus-one" href="https://plus.google.com/share?url=&lt;?php the_permalink() ?>" rel="nofollow" target="_blank" data-size="tall" data-href="<?php the_permalink() ?>"><span class="vhidden">Share on Google+</span></a></li>
          <li><a class="socialite facebook-like" href="http://www.facebook.com/sharer.php?u=&lt;?php the_permalink() ?>&t=<?php the_title() ?>" rel="nofollow" target="_blank" data-href="<?php the_permalink() ?>" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false"><span class="vhidden">Share on Facebook</span></a></li>
          <li><a class="socialite linkedin-share" href="http://www.linkedin.com/shareArticle?mini=true&url=&lt;?php the_permalink() ?>&title=<?php the_title() ?>" rel="nofollow" target="_blank" data-url="<?php the_permalink() ?>" data-counter="top"><span class="vhidden">Share on LinkedIn</span></a></li>
      </ul>

      Here is the code for above post

      <?php
      function social_before_the_content( $content ) {
          $custom_content = '<ul class="social-buttons cf">
          <li><a class="socialite twitter-share" href="http://twitter.com/share&quot; rel="nofollow" target="_blank" data-text="<?php the_title() ?>" data-url="<?php the_permalink() ?>" data-count="vertical" data-via="twitter-username-here"><span class="vhidden">Share on Twitter</span></a></li>
          <li><a class="socialite googleplus-one" href="https://plus.google.com/share?url=&lt;?php the_permalink() ?>" rel="nofollow" target="_blank" data-size="tall" data-href="<?php the_permalink() ?>"><span class="vhidden">Share on Google+</span></a></li>
          <li><a class="socialite facebook-like" href="http://www.facebook.com/sharer.php?u=&lt;?php the_permalink() ?>&t=<?php the_title() ?>" rel="nofollow" target="_blank" data-href="<?php the_permalink() ?>" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false"><span class="vhidden">Share on Facebook</span></a></li>
          <li><a class="socialite linkedin-share" href="http://www.linkedin.com/shareArticle?mini=true&url=&lt;?php the_permalink() ?>&title=<?php the_title() ?>" rel="nofollow" target="_blank" data-url="<?php the_permalink() ?>" data-counter="top"><span class="vhidden">Share on LinkedIn</span></a></li>
      </ul>';
          $custom_content .= $content;
          return $custom_content;
      }
      add_filter( 'the_content', 'social_before_the_content' );
      ?>

      Below is the code for After post

      <?php
      function social_after_the_content( $content ) {
      	$custom_content .= $content;
          $custom_content .= '<ul class="social-buttons cf">
          <li><a class="socialite twitter-share" href="http://twitter.com/share&quot; rel="nofollow" target="_blank" data-text="<?php the_title() ?>" data-url="<?php the_permalink() ?>" data-count="vertical" data-via="twitter-username-here"><span class="vhidden">Share on Twitter</span></a></li>
          <li><a class="socialite googleplus-one" href="https://plus.google.com/share?url=&lt;?php the_permalink() ?>" rel="nofollow" target="_blank" data-size="tall" data-href="<?php the_permalink() ?>"><span class="vhidden">Share on Google+</span></a></li>
          <li><a class="socialite facebook-like" href="http://www.facebook.com/sharer.php?u=&lt;?php the_permalink() ?>&t=<?php the_title() ?>" rel="nofollow" target="_blank" data-href="<?php the_permalink() ?>" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false"><span class="vhidden">Share on Facebook</span></a></li>
          <li><a class="socialite linkedin-share" href="http://www.linkedin.com/shareArticle?mini=true&url=&lt;?php the_permalink() ?>&title=<?php the_title() ?>" rel="nofollow" target="_blank" data-url="<?php the_permalink() ?>" data-counter="top"><span class="vhidden">Share on LinkedIn</span></a></li>
      </ul>';
          
          return $custom_content;
      }
      add_filter( 'the_content', 'social_after_the_content' );
      ?>

      PS. I checked these codes they work well.

  • F2

    Hi Ahmad, I was desperate to get rid of my social plugin…and heard about this cool method so thanks for posting this tutorial up (also, looking forward to the modded version on your site).

    Im having problems however getting this one going. Everything seems ok, but the buttons appear as text links (with bullet points)…like it cant see the css file.

    Any ideas?

    • http://freakify.com Ahmad Awais
      Author

      This can be the problem with your CSS file where you put the codes.
      If you use and cache plugin remove the cache. Remove your browsers cache. Press f5 several times so that browser can catch the changes.

  • http://black-and-whitephotos.blogspot.com Patil Makarand

    Excellent input, I was worried about the same 300 Kb of javascript loading on every page load. This will allow people to see the likes or share the post only If they want to. :)

    • http://freakify.com Ahmad Awais
      Author

      Thanks for liking it Patil.

  • F2

    Hi Ahmad, just this week I was reading about loading social buttons asynchronously (the plugin I used seemed to be holding up loading too)…I have almost got it working. They display, but its just txt (with button points), would that suggest it cant see the css file/sprite image? I doubled checked and everything seems ok, long shot…but any ideas? The only thing I didnt quite understand, was when you said:

    upload the socialite.min.js file, which I recommend you load in your footer.

    I didnt do that, as there was no description on how to do so.

    Thanks in advance

    • http://freakify.com Ahmad Awais
      Author

      That’s the most important part :)
      Here is an easy explantion for you, Download the Socialite.js package from this link (https://github.com/dbushell/Socialite/zipball/master) if it doesn’t works for you click Zip on this page (https://github.com/dbushell/Socialite).

      After that you will get a zip file, unzip/extract it, and upload the socialite.min.js file to your wp-content/themes/your-theme-folder/js/ folder (if the js folder doesn’t exist, create it first).

      After that follow the second step.

      • F2

        Sorry, I didn’t explain that very well, I uploaded the Socialite.min.js to the js folder and see you mention put code into the footer…but dont see where? I can only see you mention functions.php.

        Thanks Ahmad :)

        PS – I did a double post yesterday, didnt realise that posts require you to administer them before they are actually posted.

        • http://freakify.com Ahmad Awais
          Author

          So your problem solved now?

          • F2

            Nope, but Im getting closer. I copy&pasted the JS in step 2…but for some reason it changed ‘ into ‘ which somebody pointed out to me today. They also told me to check out firebug (ff addon). I had a look at the post/html and see the js mentioned in the footer :) (sorry I got myself muddled up). I also see this:

            But when searching the html on my single.php (Which has the buttons as bullet points) via firebug, I cant find a mention of these:
            wptuts-social.js
            wptuts-social.css

          • F2

            Third time lucky :)
            <script src=”/js/socialite.js” type=”text/javascript”>.

  • http://unserkaiser.com kais

    I guess

    $(‘.social-buttons’).one(‘mouseenter’, function() {

    should be .on().

  • F2

    Sorry, the code was taken out, I can see this this in the html/head:

  • http://www.bendaggers.com/ bendaggers

    exactly what I’m looking for! Still having problems on how to compress all the javascript files of google, facebook, twitter and pinterest. thanks!

    • http://www.bendaggers.com/ bendaggers

      I forgot to ask those who implemented this, have you notice huge increase in speed in loading those social networking buttons?

      sorry ’bout my 2nd comment. thank you very much again!

      • Andrea

        Well I can tell you that with social plugins the onload time of my webpage are around:

        900ms-1200ms for the dom and onload time for total is around 4 – 6 sec

        without social plugins

        600ms-850ms for the doma and 1.5 to 1.8sec for the onload time

        Testem with google chrome dev tools, pingdom and load impact.

        So yes social plugins have a huge update on loading webpages, and is better to have leazy loading.

        TIp for speeding up;
        Another step if someone from improving site performance is to defer google maps, if you use it on the home page, and show the map only on click/hover.

        • http://www.bendaggers.com/ bendaggers

          Thanks Andrea for your input! I’ll try to implement those in my website.

          I don’t have any google maps in my website but anyway, thanks for the tip!

    • F2

      Ok, well I copied tthe css into my main css files and it now displays the social sprite.png. However, even though the buttons appear, in the bubble, it has a clickable like saying “share on twitter” “share on google” etc.

      Almost there, any ideas on where to go next? It seems like the css and JS are not running correctly, when using firebug to view the single.php’s html output…I can see socialite.js, but no mention of wptuts-social.js or wptuts-social.css

      • F2

        Another update, the spriite s loaded and the text links that were in the caption box are gone and I can now see the dots. However, the sprite loads normally (no lazy load)..

        • F2

          Finally, got it working :)

          Copying the css into my main style sheet seemed to do the trick, cleared my cache etc and they now lazy load. Great, well chuffed!

          • F2

            Just incase anybody has simlilar problems, I was using (as always) sublime2 for coding…but when in work I decided to redo the tutorial (For the fourth time) and when using wordpad…it worked! I think when saving the wp css + js file, they just werent being seen. I redone them and boom…first time. Sorry about the multiple comments, I was desperate to get it working haha! All good now, will keep checking back at wptuts…I love the result.

  • Andrea

    Excellent post!

    Anyway I think that social networks should use API’s instead of iframes!

  • sridhar

    can someone give me a code when the page loads i wanna see the shared link for social icons

    $(document).ready(function()
    {

    $(‘.social-buttons’).one(‘mouseenter’, function()
    {
    Socialite.load($(this)[0]);
    });

    });

    in this script on mouseenter it changes to social link but i dont need any changes when the page loads i wanna see the social share link

    $(document).ready(function()
    {

    $(‘.social-buttons’).load( function()
    {
    Socialite.load($(this)[0]);
    });

    });

    i used this above code but still i cant see the change…….please any one help as soon as possible

  • Pingback: Tweet Parade (no.36 Sep 2012) | gonzoblog.nl

  • http://freakify.com/ Ahmad Awais
    Author

    Someone asked how to get small layout of social buttons.
    To get small layout of buttons you have to change HTML Markup. Replace the first ones with second ones
    Tweet:
    data-count=”vertical” replace it with data-count=”horizontal”
    G+:
    data-size=”tall” replace it with data-size=”medium”
    FB:
    data-layout=”box_count” replace with data-layout=”button_count”
    LI:
    data-counter=”top” replace it with data-counter=”right”

    • F2

      I was actually wanting to do this, thanks Ahmad. Can we customise the buttons/colours etc? I seen your buttons, (the ones on your blog), the uniformed layout is much nicer.

  • http://www.bendaggers.com/ bendaggers

    @Ahmad, On a very related topic.

    Is there such codes like this but this time it is for Facebook Fan Page, Follow @mytwitteraccount, and We’re on Google+ buttons?

    Again, it would be a great help if you provide us another tutorial.

  • Jeff

    Is it possible to use Pinterest with this? I see that I can add the button but when I go to the Socialite github page it is not clear how to use it and has a link to the Pinterest Goodies page http://pinterest.com/about/goodies/

    Thanks for help in advance!

  • http://mrpiratz.com/ Piratz

    i tried to combine your code with the tutorial from http://www.wpsquare.com/add-floating-lazy-load-social-share-buttons-wordpress/.. Basicly, i want put the comment icon on that social sharing button like they used.. it failed me..

    others thing is, how i can make this button float like techcrunch do?

  • http://www.macchiasnc.com paso70

    great tutorial …
    why? does not load the image into facebook post
    what is wrong!

  • Pingback: Langkah Pemasangan Butang Perkongsian Sosial Lazy-Load (Wordpress) | MrPiratz[dot]Com

  • http://famedesigner.com Ahmad Ali

    Aslam O Alikum,

    This tutorial is very helpful and fulfil many clients requirements as following this social connectivity trend.

    Thand you Awais.

  • Pingback: 【WordPressに設置するソーシャルボタン(Twitter,Facebook,Google+)の表示を遅らせて(マウスオーバー時)ページ全体の表示速度をアップさせる】 | 今村だけがよくわかるブログ

  • Cơn gió lạ

    Thanks for this tut. But what about data-count=”horizontal”?

  • Pingback: Die besten meiner geteilten Links auf Twitter im September 2012 - pixelstrol.ch

  • dan

    I got this vía @username , shouldn I see the title? ,please advise, thanks

  • Ryan S

    Nice TUT, what I notice is you assigned a list and still using this should not happen I think :)

    I think the right is ‘. the_permalink() .’, since you’re assigning it in a variable, what do you think?

    Ryan S

  • dan

    “In index.php inside the loop etc.” how do i do to place it in the left of each post, like techcrounch does?

  • http://www.facebook.com/undefeatablewarrior Carelexx Malik
  • QADiscussions

    Thanks for good plugin.. can we use this on homepage posts like mashable ?