skip to main | skip to sidebar

Google Blog Bar; jQuery-ed Version My first jQuery Plugin.. A 4KB jQuery plugin instead of a 118KB Google Blog Bar!!

I have shown before how to use Google Blog Bar as related posts widget, But when I actually tried to use it on my site, I didn't like all these JavaScript/CSS files that I've to include.
And since I already use jQuery -and who doesn't- I decided to rebuild the Blog Bar from scratch.

Of course, I'll be using the RESTful interface of the AJAX Search API that returns JSON encoded results. So I didn't scratch too much :)

Quick Definitions..
Google Blog Bar is a Google AJAX Search API application that lets you easily add page-controlled blog search results to your web pages or blog.

AJAX Search API is the easiest way to incorporate a Google search box on your site. You can incorporate results from Web Search, News Search, and Blog Search into your blog or web site with just a few lines of JavaScript.

Advantages Of My jQuery-ed Google Blog Bar:

  1. Much lighter: Using Google Blog Bar, you will have to include 3 Javascript files (2 files Actually , but fist one dynamically loads the third ):
    - Google AJAX API Loader file which is 15KB 
    - And AJAX Search API file which is 72KB
    - Google Blog Bar file which is 31KB
    -  Plus 2 CSS files that you can go without them and weighs 26KB total
    So, Total of Javascript files is 118KB vs. My 4KB Blog Bar!
    Of course, I will not count jQuery 55KB, cause -as I said- it is an essential include.
  2. More Control: Google Blog Bar will do repeated JSON queries to get more results that I didn't need and can't be disabled.
  3. It is jQuery-ed, Which is the most important :) One can add extra pretty jQuery effects..
  4. Works as related posts widget: When no query expression was set , By Default plugin use current page tags to create search expression by ORing those tags.

Implementation Steps

  1. First, download minified JavaScript of latest plugin version from project page
  2. Sign-up for an AJAX Search API Key for your website You must have a Google Account to obtain a Google API key, and your API key is tied directly to your Google Account. You can generate multiple API keys for your account if you have multiple web sites.
  3. Set your key in the default options list where it says key:'YOUR-KEY'
  4. Upload plugin Javascript file to your site. If you are on Blogger try a free file hosting that provides direct linking like FileDen. replace the link "jquery.googleblogbar-1.0.min.js" with the full direct URL you got.
    *Direct Linking: No redirection to another URL happens when you open link in a browser.
    *No need to host jQuery Javascript on your own.. Google hosts jQuery for you!
  5. Include the following CSS Code somewhere in your page usually inside Head element.
  6. Insert Code as described in the following Typical usage
  7. And the most technically important :)  Give me some Digg/Dzone love or a link back attribution.

CSS Code
The following CSS code will show a typical Blog Bar as seen in the footer below.
<style type="text/css">
/* container */{
/* inner div */
   border:silver 1px solid;
   padding:4px 12px 8px;
   margin:0 78px 0 0;
/* bar title */
div.mbb-inner h2{
   margin:0 4px 0 0;
/* ul list */
div.mbb-inner ul{
   padding:0 0 0 0;
   margin:0 0 0 0;
div.mbb-inner li{
   margin:0 0 0 0;
/** post link **/
div.mbb-inner li a{
/** author name and date **/
/** excerpt and blog url **/
.mbb-content{ }
/** powered by google **/
a.mbb-branding-link img{

Typical Usage
To show a horizontal blog bar.. place this div where you like, set options attribute and they get auto. loaded!
You will only need to include the 2 JavaScript's (jQuery and my plugin) once; even if you have more than one div.
You can defer Javascript downloading in the browser by placing the JavaScript's by the end of your page. 
Options must be separated by a comma, but a trailing comma is fatal.
<!--Inlcude once in your page-->
<script src="" type="text/javascript"></script>   
<script src="jquery.googleblogbar-1.0.min.js" type="text/javascript"></script>

<!-- Add as many as you need... div with class="my-blog-bar" -->

<!-- Show Results Restricted to "" -->
<div class="my-blog-bar" options="{title:'More Tech Tips!' , blogURL:''}">loading..</div>
<div style="clear:both"></div>

<!-- or leave it to Default options -->
<div class="my-blog-bar">loading..</div>
<div style="clear:both"></div>


Custom Usage
Load plugin content by javascript call.. <script src="" type="text/javascript"></script>   
<script src="jquery.googleblogbar-1.0.min.js" type="text/javascript"></script>
<script type="text/javascript">   

<div class="some-other-class">loading...</div>

Check Project page for detailed documentation; Follow project changes, request features or submit bugs :(

If you liked the plugin, Would you please vote for it on plugin page at jQuery site.


  1. Firdaus Ariefatosa // June 28, 2009 at 7:50:00 PM GMT+10  

    I'll try to apply this to my blog.

  2. Mike // July 24, 2009 at 11:12:00 PM GMT+10  

    You welcome, I hope applying it was smooth :)

  3. SEO Services // July 28, 2009 at 4:23:00 PM GMT+10  

    Thanks for this nice blog.

  4. Swashata // August 3, 2009 at 10:19:00 PM GMT+10  

    I also hate the size of the default blogbar! I will use this on some of my sites :)

  5. Mike // August 4, 2009 at 8:26:00 AM GMT+10  

    Great.. let me know of if you face any issues.

  6. Unknown // October 31, 2009 at 6:11:00 AM GMT+11  

    I don't know why my whole set of IFrames get flickered when transition in Blogbar happens !


    BTW Thanks for such a wonderful blogbar !

  7. Mike // October 31, 2009 at 6:26:00 AM GMT+11  

    you welcome..
    1- having a div tag with a class "my-blog-bar" should be auto-loaded into Google Blogbar as in ex:1 and then using a JS Call as in ex:2 might get 2 bars running!
    So, since you are loading the blogbar code as in ex:2 It would be better if you remove that class name from div and select it with ID
    2- try giving the outer container div a fixed height in CSS so it won't flicker.

  8. Unknown // November 4, 2009 at 2:51:00 AM GMT+11  

    Fixing a height does the job :)
    Thanks Mike !
    BTW, FYI :- The the problem was only with Firefox and that too latest update version :)
    On all other browsers it used to function normal :)

  9. Mike // November 4, 2009 at 6:00:00 AM GMT+11  

    great, thanks for the info :)

  10. valentines day presents // January 13, 2010 at 10:22:00 PM GMT+11  

    Thanks for sharing the technical information on the blog.

  11. Anonymous // March 19, 2010 at 8:00:00 AM GMT+11  

    It was working 100% on blogspot old url but when i switched to new custom domain it stopped working dunno what's happened !!!
    i signed up again for an AJAX API for my new domain (dunno if there's a difference without using www anyway i used both (with-without) ) but negative result!
    what do you think?

  12. Mike // March 19, 2010 at 8:51:00 AM GMT+11  

    try getting a new API key or use as the domain..

  13. Wesley Soccer // April 4, 2010 at 12:36:00 PM GMT+10  

    Can I use this for Just confused on where to add all the code...any help would be awesome

  14. Mike // April 6, 2010 at 1:29:00 AM GMT+10  

    sure you can.. at any of where you like in theme PHP files. something like \wp-content\themes\[theme folder]\..

Post a Comment

Thank you for taking the time to comment..
* If you have a tech issue with one of my plugins, you may email me on mike[at]
More Tech Tips! | Technology tips on web development


Mike MoreWeb developer, jQuery plugin author, social media fan and Technology Blogger.
My favorite topics are: jQuery , Javascript , ASP.Net , Twitter , Google..
<connect with="me"> </connect>

Subscribe by email

Enter your email address:

or via RSS