how to speed up social network badge loading

Reading Time: < 1 minute

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:

Reading Time: < 1 minute

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="https://www.tripit.com/account/badge/id/blabla
/div_id/tripit-badge/badge.js
"></script><noscript>
<a href="https://www.tripit.com/">TripIt - Organize
your travel</a></noscript></div>

 

The red part is what I am interested in.

https://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 https://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="https://www.momeunier.fr/cache/badge.js"></script>
<noscript><a href="https://www.tripit.com/">TripIt -
Organize your travel</a></noscript></div>

 

Note the red part again:

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

Be careful not to link to my js file…

By Marc Olivier Meunier

Marc has spent the past few years putting oil on the fire of a hyper growth ad tech company. At Smartly.io he was in charge of scaling the support and its culture. At Eficode he is now leading an engineering team and running operations. He leads by example and puts a lot of emphasis on diversity and inclusion, constantly working to create a safe environment. A warm leader with a passion for memorable experiences and innovation.
Find Marc on Linkedin

Leave a Reply

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