April 10, 2009 ~ Blogger Tutorials

There are lots of things that can’t easily be achieved in Blogger without the usage of special ‘scripts.’ As they are a growing solution for most of the features we’d like our Blogger blogs to have, we deal with a huge setback: ‘where to host them.’ We know Blogger only allows users to upload images and videos, but not other type of files.

As Blogger users, we like two things about it: it’s easy, and it’s free. But hosting isn’t, and the famous ‘free hosting services’ always have their own tricky terms related to the bandwidth consume and/or available space. Many of them are even just for ‘sharing’, and we’re not able to get from them valid, direct URLs to our hosted files.

I’ve listed some of the solutions we can apply until Google decides to give us the option of uploading other types of files.

1. Changing .js for .txt

What we call ’scripts’ are only files with plain text. They have a .js extension, which is not exactly obligatory, and it’s the reason why many hosting services won’t let us upload them.

What we can do, then, is simply changing the .js extension for a .txt extension and upload these files to Fileden, for example; then, using the provided URLs like always.

<script type="text/javascript" src="SCRIPT_URL.TXT" />

(We can upload this .txt files to Google Sites as well. Awilli, in one of this post’s comments, provides a useful link on how to do this: a tutorial from SOSwitcher.)

2. Using Google’s AJAX Libraries API

Many of the scripts we use in our blogs usually only work with certain libraries, ie. Prototype or jQuery. These, and other general libraries can be loaded in our blogs with Google’s AJAX Libraries API, adding the following code before </head> in our templates:

<script src='http://www.google.com/jsapi'/>
<script>
google.load("library if available", "version");
</script>

Here’s a complete list of the available libraries, and their installation.

3. Adding scripts directly to our templates

These kinds of code:

<script src='SCRIPT_URL' type='text/javascript'></script>

Would be replaced by:

<script type='text/javascript'>
//<![CDATA[

SCRIPT_CONTENT
//]]>
</script>

We must take in consideration that adding long scripts directly to our templates can make it a little messy and confusing; this doesn’t mean that long scripts won’t work.

4. Using Blogger’s “HTML/JavaScript” gadget

Adding long scripts to our templates might result impractical. Also, changing its .js extension for a .txt one, because of its volume, would make it consume a lot of bandwidth. Here’s a good solution for that.

In our templates, we create a new Blogger gadget section adding the following code after <body>:

<b:section class='scripts-container' id='scripts-container' />

Once this is done, from our Dashboards, in the ‘Elements Page,’ we will see a new section above our template layout. We add a “HTML/JavaScript” gadget from there, with something like this:

<script type='text/javascript'>
SCRIPT_CONTENT
</script>

We must avoid adding titles to these gadgets; however, if we’re going to add several scripts in different gadgets, we might… after adding this line before </b:skin>:

.scripts-container .widget h2 {display: none; visibility: hidden;}

Also, it seems Blogger interprets all “<” and “>” appearing in the scripts not as expected. To solve this, look for these symbols and add a space before and after each of them. Here’s an example:

Before: for(var i=0;i<a_rc;i++) {
After: for(var i=0;i < a_rc;i++) {

***

Google Pages was kind of the perfect solution for all of this; however, this beta service is soon coming to an end. Google says they will merge both Google Pages and Google Sites so we can create sites in one second; but just imagine a good and trendy site with NO JavaScript at all… I wonder why Google never merged Blogger with Google Pages, as it did with Google Adsense and Google Friends.

I could have listed some of the free services we could use, but considering what has happened with HostFile (dead already), Google Pages (dying), and lately Skydrive (not recommended), we can easily conclude that unless it is isn’t our own host, we will always have limitations.

Reference

Vagabundia [1, 2, 3]

More in this category:

blog comments powered by Disqus