Tuesday, January 10, 2006 4:56 PM Olaf Conijn

WEB 2.0 and hyperlinks that ‘preload’ their target document

"Web 2.0” applications aim at being more interactive by eliminating full page requests (and the flickering of pages between requests).
Ever since google released GMail this has been all the hype amongst web developers.

Even though this overcomes one of the usability problems we currently have with web applications, I think the biggest usability problem still remains the 1-2 second wait for a response from the server after clicking.


Hence, a silly idea I had…: What if hyperlinks would preload their target?

When browsing pages in content-centric environments you could easily use the time in between reading and clicking on a hyperlink to load the page someone navigates to on its next click. Even though preloading all links doesn’t seem like a good idea, preloading the 5 most possible succeeding pages would decrease the average wait time significantly.

Imagine a wiki that preloads the referred pages from the current entry.

…Or a searchengine that preloads the first 5 search results?

…Or a weblog engine that preloads linked pages?

Preloading rules could also be based on log file analysis, to reflect a common usage pattern or be hard coded into the html.

Below is a little example implementation that preloads all hyperlinks that have an attribute called “PreLoad” set to “true” (for example: <a href="NextPage.aspx" PreLoad="true" />). The code below might have some side effects for pages that otherwise rely on javascript (which should be easily overcome) but should give you a view on how what I meant.

<script type="text/javascript">

    Function.prototype.ExecuteWhenHttpRequestFinished=function(HttpReq, Object) {

      var r=HttpReq;

      var t=this;

      var o=Object;

      return function() {

          if (r.readyState == 4 && r.status == 200)

            t(r, o);

      }

    }

    function PreLoadHyperlinks() {

        var linksCollection = document.getElementsByTagName("a");

        for(i=0; i<linksCollection.length; i++){

            if (linksCollection[i].getAttribute("PreLoad") == "true") {

                new LinkLoader(linksCollection[i]).PreLoadTarget();

            }

        }

    }

    function GetHttpRequest() {

        try {

            return new XMLHttpRequest();

        } catch(e) {

            try {

                return  new ActiveXObject("Microsoft.XMLHTTP");

            } catch(e) { }

        }

    }

    function LinkLoader(hyperlink) {

        this.Hyperlink = hyperlink;

       

        this.PreLoadTarget=function() {

            var HttpReq = GetHttpRequest();

            HttpReq.open("GET", this.Hyperlink.href, true);

            HttpReq.onreadystatechange = this.BufferDocument.ExecuteWhenHttpRequestFinished(HttpReq, this.Hyperlink);

            HttpReq.send("");

        }

       

        this.BufferDocument=function(HttpReq, Object) {

            Object.targetDocument = HttpReq.responseText;

            Object.href="#";

            Object.onclick = function(){

                document.body.innerHTML = this.targetDocument;

                PreLoadHyperlinks();

            }

        }

    }

   

    window.onload = PreLoadHyperlinks;

    </script>

# re: WEB 2.0 and hyperlinks that ‘preload’ their target document

Tuesday, January 10, 2006 11:20 PM by Dan Bunea

Very interesting idea. I would have loved to see a live sample, but I thank you anyway.

Dan

# re: WEB 2.0 and hyperlinks that ‘preload’ their target document

Wednesday, January 11, 2006 6:53 AM by Dave

Hi Olaf -

Very interesting thought...although the percieved speed of the browsing experience would definitely be enhanced, I can't help but wonder what that would do to a) bandwidth load on web sties in general (essentially, each user could in theory be using multiple times their normal bandwidth, assuming that they did not want to click on all of the links) and b) statistics - as an administrator of many web sites, I would be concerned if I could not count on the fact that the hits in my log were in fact actual "clicks", rather than "preloads" in measuring the traffic on my web site.

Love the blog, thanks -

Dave

# re: WEB 2.0 and hyperlinks that ‘preload’ their target document

Thursday, January 12, 2006 2:05 AM by Taco

Pretty cool stuff Olaf!

Dave, i think your concerns are valid. The first concern is a trade-off; are you willing to pay the extra costs of bandwidth for the gain in extra user experience... bandwith costs are decreasing, so this concern should become less important over time.

For the second problem, the statistics, i think there are ways to circumvent this problem. For instance tagging the url of the preloaded request with an extra parameter as indication that the request was indeed preloaded..

# re: WEB 2.0 and hyperlinks that ‘preload’ their target document

Thursday, January 12, 2006 2:26 AM by Olaf Conijn

Taco, Dave

Perhaps using a pixel to track visits would be a good alternative to analyzing logfiles?

# re: WEB 2.0 and hyperlinks that ‘preload’ their target document

Thursday, January 12, 2006 2:56 AM by Michaud

Please no Olaf, thats a dummy way of doing it. If you could send the actual link clicks in the next request to the server you cna keep track of the user his activity

# re: WEB 2.0 and hyperlinks that ‘preload’ their target document

Thursday, January 12, 2006 4:37 AM by Marino vd Heijden

I think a more generic way to use statistics this way is to add a custom header in your preload request. One problem that still remains is the lack of knowledge wheater the user has actually seen the preloaded content. I believe images are only loaded when the browser needs to show them, so the dummy pixel gets interesting again...

# re: WEB 2.0 and hyperlinks that ‘preload’ their target document

Tuesday, February 07, 2006 9:48 AM by Hank Lynch

Sounds like a really good way of gaming banner programs and google ads to me. Dunno if thats all that cool.