Archive for the 'JavaScript' Category

Google Cache and slow CSS

Wednesday, October 29th, 2003

If you use Google Cache when a server isn't responding, and the page uses an external style sheet, you won't be able to see the cached page. The reason is that most browsers block page display while waiting for the style sheet to load, and Google doesn't cache CSS or images. This limits the usefulness of Google's cache, especially now that CSS is popular.

Google could cache CSS along with HTML. To avoid spidering and storing every page's CSS, Google could proxy CSS loads for Google Cache users, and have the proxy time out after 5 seconds. But both of these solutions might use a lot of bandwidth.

Google could add code to cache pages to make CSS load later or in a non-blocking fashion. This has the disadvantage that when the server is responding, the page will be presented unstyled for a split-second. Since some Google users use the cache even when the site isn't down, this would be bad.

I hoped there would be a way for Google to add code to cache pages to stop blocking loads that are taking too long. JavaScript can detect a slow load: call setTimeout above the LINK element, and call clearTimeout in another SCRIPT element below the LINK. But the function setTimeout activates can't cancel the load by disabling the style sheet, changing the LINK's href, or removing the LINK element from the document. Browser makers didn't anticipate JS trying to cancel a blocking load. (Removing the LINK element from the document even crashes IE.)

Another solution is for browsers to make CSS loads block less:

  • 84582#c11 - CSS loads should stop blocking layout if they take more than a few seconds
  • 220142 - Pressing Stop while waiting for CSS should finish displaying what has been loaded before stopping.
  • 224029 - JS can't cancel blocking load of a style sheet

Smaller Google home page

Friday, August 22nd, 2003

I edited Google's home page to make it as small as I could without changing how it looks. The result is 30% smaller and works slightly better.

Most of the changes that weren't simple deletions involved the code for the tabs above the search box.

Perception experiment videos

Saturday, August 9th, 2003

The Visual Cognition Lab at the University of Illinois has some cool videos.

In one set of videos, "Real-world person-change events", an experimenter asks a subject for directions. Two people carrying a door come between the experimenter and the subject. While the door is between them, the experimenter switches with one of the door-carriers. Subjects noticed the person change between 35% and ~100% of the time, depending on whether the experimenter was part of the same social group as the subject.

The "Gradual changes to scenes" videos are fun. Over a period of about 10 seconds, part of an image changes. Unfortunately, video compression artifacts make it easy to see the change if you focus on the correct portion of the image. I wrote Gradual image change in JavaScript with the intent of submitting it to the lab. The JavaScript works by superimposing two images and varying the transparency of the top image in increments of 1%. It works well in IE 6.0, but it's about three times too slow in Mozilla Firebird on my 1.6 GHz computer.