Pages

Showing posts with label social media. Show all posts
Showing posts with label social media. Show all posts

Wednesday, November 30, 2011

Embed Facebook, Twitter, Google Plus Without JavaScript

Search engines like Google Search use a page’s loading time as a signal when they compute that page’s ranking in their search engine results. Webmasters have a lot to tweak, from the server backbone to the scripts they use and embed, and the images and media they post; Everything has an impact on the page loading time. Social media buttons have become very popular with webmasters in recent years. The majority implements the buttons either with the help of plugins or by copying and pasting the code that social networks like Facebook offer directly.

The majority of methods use JavaScript to trigger the functionality. The issue here is that external scripts increase the page loading time. If you load to many scripts, your website could be punished for this by the search engines by reducing the page’s position in the rankings. Depending on the number of social media buttons that you embed, you could be loading multiple external JavaScript files.

But JavaScript can also be used for tracking purposes. Visitors who load a web page with external JavaScript will always at least pop up in the external service’s access logs.

The only positive effect for the webmaster is that users can vote for their articles on the linked social networking sites. But this is also achievable without JavaScript. The benefit of that solution? Faster page loading times and guaranteed no user tracking.

The following solution has been created by Daniel Pataki. It is a solution for WordPress, if you use a different script or software you may need to modify the code accordingly.

The code consists of two parts. First CSS code that you need to add to your blog’s stylesheet, and then the code that displays the links to the social networking sites on the website.

CSS Code:

You need the following sprite image that contains all four icons. This speeds up the loading time as only one image needs to be loaded instead of four separate ones. Place it in the /img/ directory of your theme folder or alter the background:url code to place it somewhere else.

sprite

.social_icon {
background:url("img/sprite.png");
display:block;
width:33px;
float:left;
margin:0 3px 0 0;
height:32px;
opacity:0.8;
filter:alpha(opacity=80);
}
.social_icon:hover {
opacity:1;
filter:alpha(opacity=100)
}
.social_icon.twitter {
background-position:-33px 0;
}
.social_icon.googleplus {
background-position:-99px 0;
}
.social_icon.print {
background-position:-66px 0;
}

WordPress single.php code

You need to add the following code to WordPress’ single.php file.

<div class='social'>
<a href='http://www.facebook.com/sharer.php?u=<?php the_permalink() ?>' class='social_icon facebook' rel="nofollow"></a>
<a href='https://twitter.com/share?url=<?php the_permalink() ?>' class='social_icon twitter' rel="nofollow"></a>
<a class='social_icon googleplus' href="https://plusone.google.com/_/+1/confirm?hl=en&url=<?php the_permalink() ?>" rel="nofollow" ></a>
<a href='javascript:window.print()' class='social_icon print'></a>
<div style='clear:both'></div>
</div>

The functionality should be available immediately. Users who click on a social networking icon are taken to the selected site where they can post about the web page that they have originated from. The page url is automatically included in the post.

I hope this helps some of you out there who want to offer functional social networking buttons without the JavaScript.

Update: Have added rel=”nofollow” to all external links.


© Martin Brinkmann for gHacks Technology News | Latest Tech News, Software And Tutorials, 2011. | Permalink |
Add to del.icio.us, digg, facebook, reddit, twitter
Post tags: , , , ,



Monday, November 21, 2011

Wallflower, Block Social Media Buttons To Speed Up Web Surfing

Every third party script that gets loaded on web sites when a visitor loads the page increases that page’s load and rendering times. Web browsers have made big improvements performance wise in recent times which has speed up page rendering times considerable. The rise of social networking sites on the other hand has seen an increase in so called social media buttons on many websites. The reason to add those buttons to web sites are simple: These buttons, if used, increase the visibility of the web site. They can also increase traffic from social media sites and decrease the site’s dependency on search engines for traffic.

The biggest usability issue can also be identified easily. Only a minority of users will make use of the social media buttons to spread the post or website. The majority of users will ignore the buttons. Even though they do, they still have to load the buttons.

Users who never use the social media buttons can install plugins or extensions that block those buttons on web sites. This reduces the overall bandwidth and the page loading times as the browser has to make fewer requests. In addition, they may increase the privacy of the user.

block facebook like google plus

The Firefox extension Wallflower blocks both the Facebook Like and the Google Plus button on most web sites. It does so automatically and without user interaction. Most means that the standard buttons are blocked. If sites implement their own version or use plugins to display the buttons then they are still displayed.

Wallflower in this regard works like previously reviewed browser extension. This includes Widgetblock for Chrome which can block additional third party buttons or the comparable extension for Firefox, ShareMeNot.

Firefox users can download and install Wallflower from the official Firefox add-on repository. I’m currently looking for ways to only load the social media buttons on Ghacks if a user requests them. The basic idea would be to display a replacement in the position, something like Share or whatever and replace the Share link with the actual buttons if a user clicks on them. While this would mean that users who want to share need to click twice to do so, it would reduce the page loading and rendering times for the majority significantly.


© Martin Brinkmann for gHacks Technology News | Latest Tech News, Software And Tutorials, 2011. | Permalink |
Add to del.icio.us, digg, facebook, reddit, twitter
Post tags: , , , ,