how to speed up social network badge loading

I have had some problem with my Tripit badge on the left of the screen. For some strange reason it wouldn’t load on my Google Chrome. It would load if I would open this page with Firefox or IE though. The weirdest thing is that after loading it from Firefox or IE, I could then load it with Chrome. 

So I decided I would take a different approach and cache the badge somewhere.

Here is how to do it:

First get the URL of the javascript file of your badge.

Here is the code of my badge:

<div id="tripit-badge"><script type="text/javascript"
src="http://www.tripit.com/account/badge/id/blabla
/div_id/tripit-badge/badge.js
"></script><noscript>
<a href="http://www.tripit.com/">TripIt - Organize
your travel</a></noscript></div>

 

The red part is what I am interested in.

http://www.tripit.com/account/badge/id/blabla/div_id/
tripit-badge/badge.js

So I am going to create a crontab in order to download that file on a regular basis.

I’ll run it every 10 mins:

*/10 * * * * wget http://www.tripit.com/blabla/badge.js \
-O /var/www/cache/badge.js

Then I’ll change the badge code to the following:

<div id="tripit-badge"><script type="text/javascript"
src="http://www.momeunier.fr/cache/badge.js"></script>
<noscript><a href="http://www.tripit.com/">TripIt -
Organize your travel</a></noscript></div>

 

Note the red part again:

http://www.momeunier.fr/cache/badge.js

Be careful not to link to my js file…

Leave a comment

Your email address will not be published. Required fields are marked *