Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Taking_Your_Talent_to_the_Web.pdf
Скачиваний:
5
Добавлен:
11.05.2015
Размер:
9.91 Mб
Скачать

46 WHY: Designing for the Medium: Web Pages Have No Secrets

So let us repeat: There is never enough bandwidth. Therefore, the best web design is that which conserves bandwidth.

Good web designers are constantly performing digital sleight of hand to conserve bandwidth. By contrast, beginning web slingers with a background in design will typically create a comp in Adobe Photoshop, cut it apart in Adobe ImageReady, and use Macromedia Dreamweaver or Adobe GoLive to put it together again as a working web page. The page may look divine, but it’s almost guaranteed to hog bandwidth.

So how do we conserve bandwidth?

Swap text and code for images

For one thing, we conserve bandwidth by using HTML text instead of typographic images wherever we can. As mentioned earlier, images must be downloaded, decoded, and expanded in the browser —and that takes time. Text may be downloaded in a fraction of the time. HTML is text-based and is thus a bandwidth-friendly technology. ImageReady is a great tool, but don’t expect it to make all your decisions for you. If you use ImageReady or Macromedia Fireworks to generate the pieces of a web page, be prepared to replace some of those pieces with bandwidth-friendly HTML.

Trim those image files

We also conserve bandwidth by reducing the file size of our images when exporting them (saving them in web-friendly formats) from Photoshop. All designers know that file sizes diminish as resolution decreases. A 1200ppi (pixels-per-inch) image takes up more megabytes than the same image at 72ppi. On the Web, all images are rendered at 72ppi, but that is only the beginning. Later in this chapter, we’ll discuss techniques for squeezing high quality out of small image files, and (again) replacing images with HTML even when you use a tool like ImageReady to automate part of the process.

Do more with less

Slicing a large image into a dozen pieces may reduce the bandwidth required by each piece, but there is a trade-off. As the server responds to one image request after another, the cumulative bandwidth used might be higher than needed to serve a smaller number of larger images. Each design requires you to experiment with these trade-offs.

Taking Your Talent to the Web

47

Prune redundancy

Another technique to conserve bandwidth is to remove redundancy from HTML code. If you’re unfamiliar with HTML, you can scan Chapter 8 for a quick overview. But even if you don’t, the following example will probably make sense to you. If not, just nod along and come back later.

In traditional web design, we use HTML tables to position text and images on the page. HTML tables are just like tables in a spreadsheet, except that the borders are usually turned off (border=”0”) to hide the underlying technology from viewers. By default, elements in a table cell are left-aligned unless the programmer has specified otherwise by typing something like <td align=”center”> or <td align=”right”>. Therefore, in an HTML layout, it is unnecessary to type:

<td align=”left”>

In our code, when:

<td>

Will suffice. Now, <align=”left”> does not eat much bandwidth on its own, but multiplied thousands of times throughout a site, that kind of unnecessary markup adds up to a significant waste of bandwidth per visitor. If the site wastes 10K of bandwidth on each visitor, and one million visitors access the site each week, the waste of bandwidth is multiplied to an astounding 10 gigabytes per week, and visitors may experience a decline in the overall responsiveness of the web server.

Strange as it seems, we can even conserve bandwidth by minimizing white space in our HTML documents. Users never see these documents unless they are utilizing View Source, and technically, the amount of white space makes no difference in the rendering of the site. For example, this HTML snippet:

<div align=”Center”> <form>

<input

type=”button” style=”font-size: 12px; font-family: geneva, arial, sans-serif; backgroundcolor: #ff6600; color: #ffffff;”

value=”Previous Reports”

48 WHY: Designing for the Medium: Web Pages Have No Secrets

onClick=”window.location=’com0800a.html’;” onMouseOver=”window.status=’More of same.’; return true;” onMouseOut=”window.status=’’;return true;”>

</form>

</div>

<p> &nbsp;<br> </p>

Is functionally identical to this HTML snippet:

<div align=”Center”><form><input type=”button” style=”font-size: 12px; font-family: geneva, arial, sans-serif; background-color: #ff6600; color: #ffffff;” value=”Previous Reports” onClick=”window.location=’com0800a.html’;” onMouseOver=”window.status =’More of same.’; return true;” onMouseOut=”window.status=’’;return true;”></form> </div><p>&nbsp;<br></p>

Note that this technique cannot be applied to the entire web page. If you mess with the white space and line breaks in JavaScript, you can generate scripting errors that cause pages to fail. It is only safe to delete the extra white space in the HTML portion of each document. HTML does not care whether the white space is there or not. But extra white space adds to the character count, which in turn, beefs up the document’s overall weight. An HTML document with plenty of white space can weigh in at 11K, while an identical document without white space may be as little as 9K. Certainly, 2K is a negligible amount of bandwidth, but multiplied by a million users a week as per the previous example, it once again becomes significant.

Before you rush off and start deleting all the white space from your HTML

files, bear in mind that white space helps the eye make sense of the code. Because a site that never changes is a site that soon loses its traffic, you will frequently find yourself reopening documents you created months before to update the content and design. Just as often, a coworker will have to open and revise a document you created, or you’ll be editing one of theirs. Moreover, web design is becoming more and more collaborative, which means more and more documents change hands throughout the process. For this reason, most web designers leave plenty of white space in their documents—along with a trail of comments which help the designer or her successors make sense of the markup.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]