RSS

Category Archives: javascript

Prefetching Files Using jQuery

>Since years, Gecko-based browsers have supported link prefetching, while other browsers (notably Internet Explorer) are lacking this function.

Here’s a simple JavaScript-based work-around based on jQuery:

$(document).ready(function() {

// Prefetch all files referenced in [LINK rel="prefetch" href="xyz"] tags...
var $prefetchTags = $('HEAD LINK[rel=prefetch][href]');

// ...starting with the ones that can be done asynchronously via AJAX...
$prefetchTags.filter('[href$=.txt],[href$=.js],[href$=.html]')
.each(function() {
$.ajax({url: this.href, dataType: 'text'});
});

// ...followed by all referenced images,
$prefetchTags.filter('[href$=.png],[href$=.jpg],[href$=.jpeg],[href$=.gif]')
.each(function() {
new Image().src = this.href;
});

It looks for all LINK tags in the HEAD section of the HTML document that have rel="prefetch" set.

Then it processes all HREF attributes, but treating text files and images differently, since text files can easily be downloaded using asynchronous HTTP requests (a.k.a. XMLHttpRequest or AJAX), while this method is not well-suited for fetching binary files.

This approach may be a bit rough on the edges, since I’ve only done limited testing, on Fireefox 3.0/Mac and MSIE 8.0/WinXP.

Advertisements
 

>Firebug 1.2 beta 2 for Firefox 3.0

>
On the Firebug blog, an announcement is posted about the release of Firebug 1.2 beta 2. It’s compatible with Firefox 3.0 RC, but not with Firefox 2.0.

For the uninitiated, Firebug is a Firefox extension that provides a host of web development tools, such as various inspectors, a JavaScript debugger, etc.

 

>WebKit (Safari) gets a new JavaScript engine: SquirrelFish

>
On “Surfin’ Safari“, the WebKit blog (WebKit being the engine for Apple‘s Safari browser) an new JavaScript engine has been announced. It’s called SquirrelFish.

While the current JavaScript engine (in Safari 3.1) is an interpreter, the new one is based on bytecode execution, increasing the possibilities for performance improvements. Already the WebKit developers are claiming a 50% improvement over the production release of Safari, version 3.1.

Although the fish logo is funny, I find it hard to associate it with speed in any way…

 

>Ajax Performance

>Here’s a great blog about client-side JavaScript and CSS: Ajax Performance. Some articles of interest:

Interesting stuff!

 
Leave a comment

Posted by on 24 March 2008 in ajax, css, ecmascript, javascript, performance

 

>Firebug is great!

>Any webdeveloper trying to debug CSS, JavaScript or AJAX should use a good tool like Firebug, a Firefox extension. It works for sure under Firefox 2.0.

One screencast says more than a thousand words:

 
Leave a comment

Posted by on 23 March 2007 in ajax, css, firebug, firefox, javascript, Web Development