Ajaxorized

Speed up your users browsing experience: preloading hyperlinks

July 27, 2008

Often, users navigate the same way through web pages. When considering this, you are able to optimize the users browsing experience by preloading web pages that are likely to be clicked next. I coded this tiny piece of javascript that loops through your hyperlinks, checks if "load" is in the rel-property, and loads the page from the href in an hidden iframe. Make sure you are using prototype.

document.observe('dom:loaded', function() {
$$('a').each(function(e) {
		if(e.getAttribute('rel') == 'load') {
			p_sHref = e.getAttribute('href');
			if(/^#/.match(p_sHref) ||  p_sHref == '' || !p_sHref) return;
			l_oIframe = new Element('iframe', {src:p_sHref} ).hide();
			document.body.appendChild(l_oIframe);
		}
	});
});


When you want a preload of you link, simply use the rel property:

<a href = "http://www.natures-desktop.com/images/Wallpaper/widescreen1920x1200/coast-beach/Southwold-Beach1.jpg" rel = "load">Testlink</a>

I'd like to hear you thoughts on this.

Add to: del.icio.us Reddit Slashdot Digg Facebook Technorati Google StumbleUpon Windows Live Yahoo
topFiled under: Prototype, Javascript | Willem @ 12:13 pm | Comments (2)

Dateslider improvements

July 13, 2008

Finally, the new version of the dateslider is available. Some changes:

  • I moved the project to google code. From now on this will be the place where you can enter your bugs and feature requests and download the script. Besides this, there is some documentation available
  • We fixed number of bugs and shortcomings from the previous version. For example, the area of dragging is limit so it is not possible anymore to drag to a place outside the box.
  • A bunch of cool new features are implemented. You can now use callback functions when a user starts and ends dragging and it is possible to zoom closer when picking specific dates.

View a demo here

And for the ones who like to cook with jQuery herbs: I'm working on it :)

Add to: del.icio.us Reddit Slashdot Digg Facebook Technorati Google StumbleUpon Windows Live Yahoo