Controlling Request Volume

Overly complex stylesheets cause only some of the difficulties up to that are exposed when designers and developers fail to optimize their designs for the benefit of server and client host performance. Most relevant to stylists’ work are the following considerations:

When possible, serve all of the files related to a single document request from a single server or local group of servers

This advice is usually impossible to follow if your project includes advertising or third-party content (i.e., multimedia files and social media tools). However, concentrating a site’s resources on a single server or network reduces the risk that a site might be rendered inoperable by failures beyond its operator’s control.

In general, reduce the number of server requests

A properly configured server host with adequate connectivity can easily honor several hundred thousand HTTP requests per hour—but that’s not the same as handling several hundred thousand visitors per hour. Even a simple, static page can imply dozens of requests for stylesheets, JavaScript files, and images. Techniques that can reduce request load include sprites, use of the style element for unique stylesheet rules, and cached concatenation of server-side markup and CSS resources via include and output buffer functions.

Place JavaScript files at the end of the page source order whenever possible

This allows all network requests and execution time required for JavaScript to be delayed until the page’s ...

Get HTML & CSS: The Good Parts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.