12.15.2012

How to upload and call javascript files from Google Servers.

When you download a template for your blog, it always contains some type of JavaScript files to trigger specific operations on demand. That operation could be a JQuery based navigation menu or Tabbed sidebar or Featured posts slider or any other effect that are based on Java script. However, you never notice these things and you just copy the template code and upload it to blogger (Excluding some curious bloggers who always take notice of what they are uploading and what kind of Java scripts are there in the template code.)

Now what’s the Problem?

Problem is simple that I also have experienced a few times in my early days of blogging. Sometimes, these java scripts are delayed or even don’t work at all distorting the look and functionality of your blog. These JavaScript files simply don’t work as these were intended to be.

Why this happens?

These JavaScript are files are uploaded to a particular server, usually the same server from where you are getting template. If there are too many users for the same template, everyone is calling their JavaScript from the same server, and servers are not good enough to provide all the bandwidth then you face this kind of problem.

2nd Problem is the up-time of the server, If that server is doing some maintenance and down for a good time, your JavaScript will also not work.

What is the solution?

How about uploading the JavaScript files to a place of your own choice, So that you are not depending on others ‘servers to make your blog fully functional all the time?

How about using Google’s server to host JavaScript where you can upload it for free? You know that Google Servers are more efficient than any other server is and up time is almost more than 99.99%.

So how to do it?

First of all, you need to find the URL of your JavaScript code.

You can find all the JavaScript files in your template.

1.    Expand the template code.

2.    Find “.js” through browser’s search function. Normally, all the JavaScript url ends at .js.

3.    After finding the url, copy it, and paste this url in browser bar.

4.    Script will be opened in the browser window or alternatively browser will prompt you to save the file. You can save it ad open it in Notepad.

I am taking a particular example here to elaborate the process.  This example uses already a Google hosted JavaScript.

Say this is the JavaScript code.

<script src='http://blogergadgets.googlecode.com/files/related-posts-with-thumbnails-for-blogger-pro.js' type='text/javascript'/>
If I paste http://blogergadgets.googlecode.com/files/related-posts-with-thumbnails-for-blogger-pro.js in browser then see below the screenshot with Snipping tool.




5.     Save it, then open it and copy the code and make a .txt file and save it again.

6.    Now, in case if you don’t have it already, create a Google site from this link. (Its free!)

7.    After creating this website, create a new page in this website and search for “attachment” link. Upload your txt file here.

8.    This file will have a specific URL. Copy the URL by using right click of mouse and copy URL option.

9.    Paste this URL in browser bar

Remove the highlighted part as in below screenshot. 


Copy the remaining part of URL and replace it with the original URL in the JavaScript code.

And you are done!

IF you have any problem in implementing this method or you have anyother question please leave a comment below.

Rizwan M.

Rizwan is a Ph.D. candidate at National University of Singapore (NUS) in the field of tissue engineering, biomaterials and nanotechnology. You can read more about him HERE