O'Reilly logo

Lean Websites by Barbara Bermes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6Producing Lean Web Assets: Part 1

Warm Up

While the previous chapter explored techniques for reducing and optimizing HTTP requests in general, this chapter will focus on optimizing individual web assets such as HTML, CSS, and JavaScript.

Optimizing HTML

When writing HTML, make sure it is semantic, valid, and as lean as possible. The more errors your code contains, and the more nested elements you have, the more work you are requiring of the browser. (The browser will do its best to correct your errors as it constructs the DOM, but there's only so much it can do.)

Move any inline styles from HTML elements into your style sheets. For example, instead of writing <div style="color:red">, use div {color:red} in a separate style sheet.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required