Beyond Caching: Google engineers reveal secrets to faster Web sites

Better JavaScript memory management and HTML prefetching tags could make Web sites more responsive

By , IDG News Service |  Software

To improve performance, and better manage memory, developers should use an approach similar to the one used by the middleware library Emscripten, which is being used to build high performance HTML5 Web games.

Emscripten converts code written in C or C++ into JavaScript, allowing it to manage memory from within the application itself. An Emscripten-based program will pre-allocate a block of memory from the system. The programmer, along with Emscripten itself, decides when memory is no longer needed, and Emscripten returns this unused memory to its pool of internally available memory. The JavaScript engine does not do any garbage collection on the program and so would not affect the performance of the program.

Generally speaking, programs written with this technique can run two to four times faster than typical JavaScript programs and do not suffer from the occasional lag in performance that GC operations can cause, McAnlis said.

Another Google presentation, from Google Web performance engineer Steve Soulders, pointed to some of the emerging browser techniques of fetching Web pages even before they are requested by the user.

The idea is that the browser, Soulders explained, should be able to anticipate the next page that its user might want to see, even before the user requests the page.

"You don't know what the user's next step will be, but you could get more clues as to [his or her] intent on the page" they just requested, Soulders said. He then explained several techniques for exploiting this knowledge.

Developers can add the HTML dns-prefetch, pre-fetch and pre-render tags to a page's hyperlinks. Once a page is loaded, such tags can tell the browser to fetch some of the contents of the pages that are linked to in that original page, even before the user requests them.

The dns-pre-fetch tag tells the browser to look up the domain name of the Web page link. The pre-fetch tag tells the browser to grab the entire page, and the pre-render tag calls for the browser to construct the entire page, as if it were displaying the page on a hidden tab.

All three of these tags, when deployed, can shorten the period between requesting a Web page and seeing that Web page.

Soulders warned developers to use such tags wisely, because they can drive up bandwidth and processor usage. But in many cases, such as a log-in page, or for a page of search results, there is a fairly high likelihood that a user will click on one of the links found on the page they've been delivered.

Join us:






Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Ask a Question