Netscape DevEdge

Skip to: [content] [navigation]

Tips For Authoring Fast-loading HTML Pages

These tips are based upon common knowledge and experimentation. If you have additional pointers to help others improve the page load performance of their web pages, we would welcome your suggestions.

An optimized web page not only provides for a more responsive site for your visitors, but also reduces the load on your web servers and internet connection. This can be crucial for high volume sites or sites which have a spike in traffic due to unusual circumstances such as breaking news stories.

Optimizing page load performance is not just for content which will be viewed by narrow band dialup visitors. It is just as important for broad band content and can lead to dramatic improvements even for your visitors with the fastest connections.


  1. Reduce page weight, which is by far the most important factor in page load performance.

    Reducing page weight through the elimination of unnecessary whitespace, comments and moving inline script and css into external files can improve download performance with minimum other changes in the page structure.

    Tools, such as HTML Tidy, can automatically strip leading whitespace and extra blank lines from valid HTML source. Other tools can "compress" JavaScript by reformatting the source or obfuscating the source and reducing long indentifiers to shorter versions.

  2. Minimize the number of files.

    Reducing the number of files referenced in a web page lowers the number of HTTP connections required to download a page.

    Depending upon a browser's Cache settings, it may send an If-Modified-Since request to the web server for each CSS, JavaScript or image file, asking if the file has been modified since the last time it was downloaded.

    By reducing the number of files referenced in a web page, you reduce the time required for these requests to be sent and their responses received.

    Too much time spent querying the last modified time for referenced files can delay the initial display of a web page since the browser must check the modification time for each CSS or JavaScript file before rendering the page.

  3. Reduce domain lookups.

    Since each separate domain costs time in a DNS lookup, reducing the number of separate domains used to reference CSS, JavaScript and images reduces page load times.

    This may not always be practical, however, you should always be careful to only use the minimum number of different domains in your pages as is possible.

  4. Cache reused content.

    Make sure that any content that can be cached is cached with appropriate expiration times.

  5. Optimally order the components of the page.

    Download page content first so the user gets the quickest apparent response for page loading.

    The content of the page along with any CSS or JavaScript required for its initial display should be downloaded first. This content is typically text and can benefit from text compression in the modem thus providing a quick response to the user.

    Any DHTML features that require the page to complete loading before being used should be initially disabled and only enabled after the page loads. This will allow the DHTML JavaScript to be loaded after the page contents thus improving the overall appearance of the page load.

  6. Reduce the number of inline scripts.

    Inline scripts can be expensive for page loading since the parser must assume that an inline script can modify the page structure. Reducing the use of inline scripts in general, and reducing the use of document.write to output content in particular can improve overall page loading. Use modern W3C DOM methods to manipulate page content for modern browsers rather than the older approaches based on document.write.

  7. Use modern CSS and valid markup.

    Use of modern CSS reduces the amount of markup, can reduce the need for images in terms of layout, and can in many ways replace images which are actually only images of text and cost much more than the equivalent CSS and text.

    Using valid markup has other advantages. Not only do browsers not have to perform "error correction" when parsing the HTML, valid markup allows free use of other tools which can pre-process your web pages. For example, HTML Tidy can remove whitespace and remove optional ending tags however it will refuse to run on a page with serious markup errors.

  8. Chunk your content.

    Either replace table-based layout with divs or break tables into smaller tables that can be displayed without having to download the entire page contents.

    Rather than deeply nesting tables as in:


    use unnested tables or divs as in

  9. Specify sizes for images and tables.

    If the browser can immediately determine the height and/or width of your images and tables, it will be able to display a web page without having to reflow the content. This not only speeds the display of the page but prevent annoying changes in a page's layout when the page completes loading.

    Images should have height and width specified.

    Tables should use the CSS rule table-layout: fixed and specify widths of columns using COL and COLGROUP tags.

  10. Choose your user agent requirements wisely.

    To achieve the greatest improvements in page design make sure that reasonable user agent requirements are specified for projects. Do not require your content to appear pixel-perfect in all browsers, especially not in downlevel browsers.

    Ideally, your basic minimum requirements should be based upon modern browsers which support the relevant standards. This can include: Netscape 7/Gecko 1.0.2+ on any platform, Internet Explorer 5.5+ on Windows, Opera 7+ on Windows and Safari on Mac OS X.

    Note however that many of the tips listed in this Technote are common sense techniques which apply to any user agent and can be applied to any web page regardless of browser support requirements.

Example page structure: