Using the window.location property in Javascript

I often forget how this works, so here is the different properties of window.location.
Thanks to DevGuru for the data.

To see how these work, pop open your firebug and add them to your console box and run them.

The properties:


The hash property is a string beginning with a hash (#), that specifies an anchor name in an HTTP URL.

The host property is a string comprising of the hostname and port strings.


The hostname property specifies the server name, subdomain and domain name (or IP address) of a URL.


The href property is a string specifying the entire URL, and of which all other Link properties are substrings.


The pathname property is a string portion of a URL specifying how a particular resource can be accessed.


The port property is a string specifying the communications port that the server uses.


The protocol property is the string at the beginning of a URL, up to and including the first colon (:), which specifies the method of access to the URL.

The search property is a string beginning with a question mark that specifies any query information in an HTTP URL.

Loading your javascript files asynchronously

So it’s widely understood now, that performance has a direct effect on the traffic of our site.   This puts performance at a much higher priority than before.. especially if your site traffic is what pays the bills.  Steve Souders began working on website performance, initially thinking that backend performance was the key, but he quickly found out that most of the performance could be gained on the front end, with far less work than optimizing sql queries and refactoring backend code.  Since he started publishing his work, we have seen a progression of understaning what helps our websites perform better.  Here is a list of things that we can look to accomplish quickly and see vast performance improvements.

  • minification of files
  • zipping css / js files
  • pulling all css files into one
  • pulling all js files into one
  • creating image sprites that combined many images into one big sprite
  • avoid using IE specific css expressions
  • using a cdn to serve files
  • loading js at bottom of page
  • serving files from a different domain
  • serving files asynchronously after page has loaded

Want to know more about the above performance enhancements?  Go to the Yahoo Developer article explaining them in detail.   Also keep in mind that your mileage may vary.  We found this out at my current job, since we took are most popular pages, and removed all the less important parts of the page, and added them via ajax, after the page loaded.   This made the pages load screaming fast!  However, our server peaked out very quickly because it was doing about 5 times the amount of requests.  Each ajax request, even when cached, requires resources from your server.  Needless to say, we don’t have the money to drop into several more servers, so lazy loading via ajax will have to wait. Keep things like that in mind when adding performance techniques to your site.

Okay Okay, get on with it!

So you have an idea of whats going on with website performance, and the last part of the list was about serving files asynchronously after page load.   Here is a little script that simply loads files after the page has loaded

And to load these files, you only need to call the function with the script as the argument

Really, that’s about it. Fairly simple script as you can see, yet very powerful, this was basically borrowed from Google Analytics implementation of their asynchronous loading analytics.
One thing to note: I am loading the files in the opposite order than usual. The jquery.js file should be loaded first in the dom.. but since we are using insertBefore.. the first must be last and the last must be first.

TextMate command: dummy text generator instead of lorem ipsum

I hate having to go to a page every time I need dummy text like lorem ipsum. So I searched out for a random dummy text generator for my beloved TextMate. Unfortunately, the ones I did find, required another language installed, like Ruby, so I looked into creating one for bash. (since bash is installed by default and it’s the default language for making TM commands.

I created array’s of dummy paragraphs, then I echoe’d one of those paragraphs randomly.
Here is the code.

ARRAY[0]="Auf ya strudel octoberfest hinder ..."
ARRAY[1]="Auf nine die stoppern nine nicht ..."
ARRAY[2]="Sauerkraut leiderhosen du er strudel ..."
ARRAY[3]="Poppin stoppern pukein, frau mitten ..."
ARRAY[4]="Verboten handercloppen zur hast spitzen ..."
ARRAY[5]="Glockenspiel flippin oof sparkin achtung ..."
ARRAY[6]="Rubberneckin blitz pretzel weiner heiden ..."
ARRAY[7]="Ya frau sightseerin noodle thinken stoppern ..."
ARRAY[8]="Deutsch, unter der meister spritz pretzel ..."
ARRAY[9]="Bin octoberfest sauerkraut meister hinder ..."
echo ${ARRAY[((RANDOM%10))]}

and here is how to add it to your Textmate or BBEdit.

Textmate's command editor window with all it's settings

Textmate's command editor window with all it's settings

So I hope that helps, for those of you whom want an easy way to add dummy text to their coding.
type “lipsum” and press TAB..

Oh you say, you want to know where I got the dummy text?

That’s pseudo-german, using the Greeking Machine at Duck Island.

Or get regular Lorem Ipsum at