Slow loading with Google Analytics

I experienced my pages slowing down when using Google Analytics togheter with my Firefox AddOn NoScript. Since I’m far from the only one using NoScript I found this not acceptable and worked out a possible work around.

The reason for the slow down is likely the timeout of the connection between my domain (where I’ve allowed scripts to run) and Googles domains (where I might or might not have allowed scripts).

Googles code look like this (where “UA-1111111-1” is your tracking ID):

<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-1111111-1”);
pageTracker._initData();
pageTracker._trackPageview();
</script>

The first part of the code creates an obfuscated loading of the script located at google-analytics.com/ga.js. It picks a prefix of www if it’s a standard connection and ssl if it’s  an encrypted connection. The problem is that NoScript does not recognize this code and ends up in a deadlock of wether or not to allow the script to be run. My guess is that there is another script loaded from another domain called googlesyndication.com which fails to enter the NoScript-test and locks the loading of the page.

A possible fix that I’m still evaluating but which should do the trick is the following (code in bold added):

<script src=”http://www.google-analytics.com/ga.js” type=”text/javascript”></script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-1111111-1”);
pageTracker._initData();
pageTracker._trackPageview();
</script>

As you can see I’ve made the obfoscated code clear text code and chosen the http://www-prefix (since I’m not using an encrypted connection for my server). Should you use encryption on your site simply switch http://www to https://ssl instead (this is what the javascript used to do). If you have a page which might be loaded encrypted or normally then you would have to include this choice earlier in a server side script for example.

After this fix Google Analytics works like a charm togheter with NoScript on any script-level setting for me.

Try this at your own risc, this is still experimental to me as well!

Firefox profiles – tips & tricks

With the latest version of Firefox I’ve found myself using more and more Addons for specific purposes. I also started “saveing” open tabs when closing, to easier get back into my blogging / working again. Due to these reasons I found myself wanting a “work Firefox” and a “casual surfing Firefox” (mainly for other people who sometimes use my computer so they don’t “mess” with my work Firefox).

Luckily the profile system in Firefox can solve this quite easily! If you want multiple profiles within the same login on a computer follow these simple steps:

1: access the profile manager

You have to add at least one more profile, or however many you want on the same machine. To do this run firefox with the following argument:  –profilemanager

The easiest way to do this is to change the shortcut destination like so:

“C:Program FilesMozilla Firefoxfirefox.exe” –profilemanager

Please note that the path should not be changed, only the addition of the profilemanager argument.

2: create new profiles

Start Firefox using this command and simply choose “add profile” and name the profiles you want.

3: Create shortcuts to profiles

When you have the profiles you want you can either always use the profile manager (or check the “always ask” checkbox) or you can create custom Firefox shortcuts that opens a particular profile with the -d [profile] argument. For example, to start the defualt profile use the following command:

“C:Program FilesMozilla Firefoxfirefox.exe” -P default

You can now copy the shortcuts and make a shortcut to each profile you want easy access to. Each profile will be totally seperate with own AddOns, History, Tabs and Settings.

Firefox 3.0 follow up

After a few weeks of Firefox 3 usage I must say I now do not miss Internet Explorer at all. With the add-ons available I’ve managed to customize my web browser exactly how I want it (only a few innovative ideas I have myself are missing).

It’s proven it’s stable and fast, I’ve used it on a mixture of laptops and operating systems (Ubuntu 8.04 and several Windows versions) and everywhere it has worked as perfect as could be expected.

As I earlier argued it has several advantages over Internet Explorer and I will now go in depth on one of the advantages: AddOns.

Firefox AddOns are programs that extend the functionality of the web browser and I will rank the best I’ve come across so far.

Recommended addons
Everywhere I install Firefox I always install 2 particular AddOns, Adblock Plus and NoScript. These two make surfing the web safer and faster and despite NoScript requering some interaction when visiting new sites I do not find this bothers me at all. The ad-blocker works fantasticly with the EasyList subscription that contains some standard filters for ads.

After the two “essential” Addons I usually pick up the IE Tab addon.  With this addon you can choose to open sites or links in a tab that is powered by Internet Explorer. You can also write a filter so that some pages (like Windowsupdate.com, Microsoft.com and such) are always opened in IE Tab, this saves you from having to switch browser for sites programmed entierly for Internet Explorer.

If you not only just surf the web but also use FTP the FireFTP addon is worth a look. While being far from the best FTP client I’ve seen it gets the job done and is very easy to use.

Del.icio.us have been a great tool for bookmark handling and the latest installment of a Firefox addon does not dissapoint. Easy interface and installation, though a word of caution: if you run NoScipt make sure to have del.icio.us on the whitelist for scripts or the installation will fail.

Those where my recommendations for now, since I’m soon on a holiday I don’t think I will have time to check out all the developer addons available but I sure will when I get back to work.