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 viainclude
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.