Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Image

Even Faster Web Sites 171

Michael J. Ross writes "Slow Web page loading can discourage visitors to a site more than any other problem, regardless of how attractive or feature-rich the given site might be. Consequently, many Web developers hope to achieve faster response times using AJAX (Asynchronous JavaScript and XML), since only portion(s) of an AJAX page need to be reloaded. But for many rich Internet applications (RIAs), such potential performance gains can be lost as a result of non-optimized JavaScript, graphics, and CSS files. Steve Souders — a Web performance expert previously at Yahoo and now with Google — addresses these topics in his second book, Even Faster Web Sites: Performance Best Practices for Web Developers." Read on for the rest of Michael's review.
Even Faster Web Sites
author Steve Souders
pages 254 pages
publisher O'Reilly Media
rating 8/10
reviewer Michael J. Ross
ISBN 978-0596522308
summary Advanced techniques for improving website performance.
The book was published by O'Reilly Media on 18 June 2009, under the ISBN 978-0596522308. The publisher makes available a Web page, where visitors can purchase the print and electronic versions of the book (as well as a bundle of the two), read the book online as part of the Safari library service, and check the reported errata — comprising those confirmed by the author (of which there are currently two) and any unconfirmed errors (all six of which are valid, though the fifth one may be a coincidence). In a break with traditional practice among technical publishers nowadays, there is no sample chapter available, as of this writing.

In many ways, this second book is similar to Steve's previous one, High Performance Web Sites: It presents methods of enhancing the performance of websites, with a focus on client-side factors. It is fairly slender (this one is 254 pages), relative to most programming books nowadays, and the material is organized into 14 chapters. However, unlike its predecessor, Even Faster Web Sites emphasizes generally more advanced topics, such as script splitting, coupling, blocking, and chunking (which to non-developers may sound like a list of the more nefarious techniques in professional hockey). This second book also has employed a team approach to authorship, such that six of the chapters are written by contributing authors. In his preface, Steve notes that the 14 chapters are grouped into three broad areas: JavaScript performance (Chapters 1-7), network performance (Chapters 8-12), and browser performance (Chapters 13-14). The book concludes with an appendix in which he presents his favorite tools for performance analysis, organized into four types of applications: packet sniffers, Web development tools, performance analyzers, and some miscellaneous applications.

In the first chapter, "Understanding Ajax Performance," guest author Douglas Crockford briefly describe some of the key trade-offs and principles of optimizing applications, and how JavaScript now plays a pivotal role in that equation — as websites nowadays are designed to operate increasingly like desktop programs. On pages 2 and 3, he uses some figures to illustrate fixed versus variable overhead, and the dangers of attempting to optimize the wrong portions of one's code. By the way, the so-called "axes" are not axes, or even Cartesian grid lines, but simply levels. Aside from its choppy narrative style and a pointless religious reference in the first paragraph, the material serves as a thought-provoking springboard for what follows. Chapter 2, titled "Creating Responsive Web Applications," was written by Ben Galbraith and Dion Almaer, who discuss response times, user perception of them, techniques for measuring latency, browser threads, Web Workers, Google Gears, timers, and memory issues. The material is neatly explained, although Figure 2-2 is quite confusing; moreover, both of the figures on that page should not have been made Mac- and Firefox-specific.

In the subsequent four chapters, Steve dives into the critical topic of how to optimize the performance of JavaScript-heavy pages through better script content and organization — specifically, how and when to split up large scripts into smaller ones, how to load scripts without blocking one another or breaking dependencies within the code, and how to best in-line scripts, when called for. Each of the four chapters follows an effective methodology: The first author delineates a particular performance mistake made by even some of the most popular websites, with the statistics to back it up. He presents one or more solutions, including any relevant tools, again with waterfall charts illustrating how well the solutions work. Lastly, he explains any browser-specific issues, oftentimes with a handy chart showing which possible method would likely be optimal for the reader's given situation, such as expected browser choices in the site's target audience. When there are potential pitfalls, Steve points them out, with helpful workarounds. He generally provides enough example source code to allow any experienced developer to implement the proposed solutions. Unfortunately, the example code does not appear to be available for download from O'Reilly's website.

The discussion of JavaScript optimization is capped off by the seventh chapter, written by Nicholas C. Zakas, who explains variable scope within JavaScript code, the advantages of choosing local variables as much as possible, scope chain augmentation, the performance ramifications of the four major data types (literal values, variables, arrays, and objects), optimizing flow control statements, and string concatenation. He outlines what sorts of problems can cause the user's Web browser to freeze up, and the differing responses she would see depending upon her chosen browser. Nicholas concludes his chapter by explaining how to utilize timer code to force long-running scripts to yield, in order to avoid these problems. By the way, in Figures 7-2 and 7-3, the data point symbols need to be enlarged so as to be distinguishable; as it is, they are quite difficult to read. More importantly, on page 93, the sentence beginning "This makes array lookup ideal..." is either misworded or mistaken, since array lookup cannot be used for testing inclusion in ranges.

With the eighth chapter, the book shifts gears to focus on network considerations — namely, how to improve the site visitor's experience by optimizing the number of bytes that must be pushed down the wire. In "Scaling with Comet," Dylan Schiemann introduces an emerging set of techniques that Steve Souders describes as "an architecture that goes beyond Ajax to provide high-volume, low-latency communication for real-time applications such as chat and document collaboration" — specifically, by reducing the server-side resources per connection. In Chapter 9, Tony Gentilcore discusses a rather involved problem with using gzip compression — one that negatively impacts at least 15% of Internet users. Even though videos, podcasts, and other audiovisual files consume a lot of the Internet's bandwidth, images are still far more common on websites, and this alone is reason enough for Chapter 10, in which Stoyan Stefanov and Nicole Sullivan explain how to reduce the size of image files without degrading visible quality. They compare the most popular image formats, and also explain alpha transparency and the use of sprites. The only clear improvement that could be made to their presentation is on page 157, where the phrase "named /favicon.ico that sits in the web root" should instead read something like "usually named favicon.ico," since a favicon can have any filename, and can be located anywhere in a site's directory structure.

The lead author returns in Chapter 11, in which he explains how to best divide resources among multiple domains (termed "sharding"). In the subsequent chapter, "Flushing the Document Early," Steve explores the approach of utilizing chunked encoding in order to begin rendering the Web page before its full contents have been downloaded to the browser. The third and final section of the book, devoted to Web browser performance, consists of two chapters, both of whose titles neatly summarize their contents: "Using Iframes Sparingly" and "Simplifying CSS Selectors." That last chapter contains some performance tips that even some of the most experienced CSS wizards may have never heard of before. As with most of the earlier chapters, the narrative tends to be stronger than the illustrations. For instance, Figure 14-5, a multiline chart, is quite misleading, because it appears to depict three values varying over time, when actually each of the ten x-axis coordinates represents a separate major website. A bar chart would obviously have been a much better choice.

Like any first edition of a technical book, this one contains a number of errata (aside from those mentioned earlier): In Figure 1-1, "iteration" is misspelled. On page 23, in the sentence beginning "Thus, if...," the term "was" should instead read "were." In Figures 7-1 and 7-4, the "Global object" box should not contain "num2." On page 95, in the phrase "the terminal condition evaluates to true," that instead should read "false." On page 147, in the sentence beginning "However, the same icon...," the "was" should instead read "were." On page 214, "Web-Pagetest. AOL" should instead read "Web-Pagetest, then AOL," because the first sentence is one long absolute phrase (i.e., lacking a finite noun and verb).

All of these defects can be easily corrected in future printings. What will probably need to wait for a second edition, are improvements to the figures that are in need of replacement or clarification. What the publisher can rectify immediately — should the author and O'Reilly choose to do so — would be to make all of the example source code available for download.

Even though this book is decidedly longer than High Performance Web Sites, and has many more contributing authors, it does not appear to contain as much actionable information as his predecessor — at least for small- to medium-sized websites, which probably make up the majority of all sites on the Web. Even though such methodologies as Comet, Doloto, and Web Workers appear impressive, one has to wonder just how many real-world websites can justify the development and maintenance costs of implementing them, and whether their overhead could easily outweigh any possible benefits. Naturally, these are the sorts of questions that are best answered through equally hard-nosed experimentation — as exemplified by Steve Souders's admirable emphasis upon proving what techniques really work.

Fortunately, none of this detracts from the application development and optimization knowledge presented in the book. With its no-nonsense analysis of Internet performance hurdles, and balanced recommendations of the most promising solutions, Even Faster Web Sites truly delivers on its title's promise to help Web developers wring even more speed out of their websites.

Michael J. Ross is a freelance Web developer and writer.

You can purchase Even Faster Web Sites from amazon.com. Slashdot welcomes readers' book reviews — to see your own review here, read the book review guidelines, then visit the submission page.

*

This discussion has been archived. No new comments can be posted.

Even Faster Web Sites

Comments Filter:
  • by Anonymous Coward on Wednesday July 22, 2009 @01:48PM (#28784583)

    Slashdot is the SLOWEST web site on the net.

  • AJAX (Score:5, Insightful)

    by metamechanical ( 545566 ) on Wednesday July 22, 2009 @01:50PM (#28784611)
    Has anybody else noticed that of all the websites visited, some of the SLOWEST make heavy use of AJAX? Or is that just me?
  • by Anonymous Coward on Wednesday July 22, 2009 @01:51PM (#28784639)

    See slashdot, slow loading pages == bad.

    I hope this book helps you.

  • by eln ( 21727 ) on Wednesday July 22, 2009 @02:02PM (#28784815)
    Slashdot isn't slow, it's just buggy as hell.
  • Re:AJAX (Score:4, Insightful)

    by Archangel Michael ( 180766 ) on Wednesday July 22, 2009 @02:07PM (#28784907) Journal

    Conversely, some of the fast websites use basic TEXT and skimp on the graphics.

    I do websites for non-profits and I one of my rules in doing a website is NO UNNECESSARY graphics. Graphics that add pretties but don't add anything else are not allowed. I also run all the graphics through a size filter to limit unneeded pixel count and quality. You don't need 25MB photo on the front page; a scaled and reduced quality is a better choice.

    My way of saying this is, "I don't need to see the pimples on the porn stars butt". Sometimes too much detail is too much.

  • Wait a second... (Score:3, Insightful)

    by damn_registrars ( 1103043 ) <damn.registrars@gmail.com> on Wednesday July 22, 2009 @02:08PM (#28784925) Homepage Journal
    At first I thought this would help the slashdot coders, until I read more closely:

    Slow Web page loading can discourage visitors to a site more than any other problem, regardless of how attractive or feature-rich the given site might be

    Attractive and feature-rich are not adjectives that are appropriate to apply to slashdot it its current form. Hence I don't think this book is the cure to what ails them.

  • Or how about... (Score:5, Insightful)

    by castironpigeon ( 1056188 ) on Wednesday July 22, 2009 @02:09PM (#28784953)
    Most websites don't need to be ridiculously complicated to be effective. Go ahead and call me a luddite, but does everyone need comments on their website? Fancy sliding menus? Pop-up image galleries? Flash or other web programming up the wazoo?

    When did simple, efficient web design that presents content well and doesn't get in the way of it get tossed out the window?
  • by MogNuts ( 97512 ) on Wednesday July 22, 2009 @02:14PM (#28785017)

    "Classic" /. was always fast posting that I recall. I just wish I could have the features of the new /. (read: "the +/-" to meta-mod stories), with the old that was lost (read: ability to only display stories from certain sections, rather than only by author it seems now).

    And maybe it's just me, but where is the option to not timeout your login? I don't want auto-login or to stay logged in after I close the browser (for security), but I hate that /. logs me out after only like 2 minutes of inactivity. I can't even read half a discussion before I go to post and it says to login. Drive me mad, it's been over 10 years now lol!

  • Re:AJAX (Score:4, Insightful)

    by iknowcss ( 937215 ) on Wednesday July 22, 2009 @02:22PM (#28785149) Homepage
    You're right, but it's not the AJAX that is the cause. It's the incompetent "web developers" who think AJAX is going to solve all of their problems by getting them a better job and making them worth more. These are the same people who firmly believe that Ruby on Rails is the only way to create an AJAX application and not-so-coincidentally couldn't code their way out of a paper bag. I should know. I went to high school with them :)
  • K.I.S.S. (Score:4, Insightful)

    by Tablizer ( 95088 ) on Wednesday July 22, 2009 @02:32PM (#28785281) Journal

    The fastest websites I see generally use plain-jane HTML and pre-sized graphics (via size attributes on IMG tag). AJAX, CSS, and too much JavaScript seem to cause confusing UI behavior, unexpected pausing while something fancy is doing GC, or jerky scroll motion that can be perceived as sluggishness, especially on older hardware.

  • by Anonymous Coward on Wednesday July 22, 2009 @02:37PM (#28785363)

    Slashdot is the SLOWEST web site on the net.

    You obviously haven't had to suffer through the bloated shit that Gawker Media forces upon its victims [jalopnik.com]. Not only does their slower-than-Slashdot Javashit have to be enabled to view comments, and comments were just changed to be forcibly presented in reverse chronological order. Always. No user-configurable option to sort 'em chronologically. Image galleries are forcefed as slideshows; no click-to-open-in-tab ability.

    I used to visit Jalopnik multiple times a day, and am now down to once or twice a week, and now actively avoid Gawker's other properties. The only other "design" that ever annoyed me enough that I pre-emptively avoid reading anything they do was the Forbes fetish for the Top 10 Slide Show, but the new Gawker is right up there. Compared to that, the pile of bloated Javashit that is Slashdot is tame by comparison -- because unlike the other sites, at least we can turn all the crap off (classic view) and still read the comments.

  • by Anonymous Coward on Wednesday July 22, 2009 @02:39PM (#28785387)

    I've seen a lot of good sites "re-designed" into oblivion. I think it's mostly a social problem.

    1. The "we're artistes" mentality. Unless your site is explicitly an art site (which it usually isn't), people will just want information from your site. You could do most of that with static HTML and a few simple images.

    2. The "we're losing eyeballs, we need to do something" problem. The site design is an easy target; but it may not be your site design. Maybe your content is just boring. Competition moved in. You were participating in a fad. The honeymoon is over. The public tastes change. You can't control those things, but you can control your site design so that's what you do. It's like pushing the walk button at an intersection when somebody else has already pushed it.

    3. Now, this is the one I really hate to say; but here goes... "You can't figure out how to let people go". The project is done. You need a few maintenance coders, the most experienced people. OK, maybe there's some justification for keeping staff around for new projects; but I bet often there isn't. If you're directly involved with the developers, you don't want to do this. The risk is that you'll spark brain-drain and cause the people you really need to leave. It's far less risky for you to keep everybody, even the grunts. Better yet, you can go up to the next level of management and tell them that site redesign is needed. That makes you the hero instead of the villain. The next level up from you is probably not going to figure out that you are just trying to keep your department busy. Perhaps this problem could be solved by making it clear right from the start that there will be a permanent staff and some contract workers. Instead, I bet there are a lot of companies where the web developers figured out how to justify their existance--to the detrement of the site, and the company.

    4. Cool new technology. 'nuff said.

    5. People just aren't that bright. They dynamicly generate javascript via a scripting language with a framework on top of it. Just to put "Hello World" on a page. Look at me! I'm a web developer.

  • Re:No... (Score:4, Insightful)

    by Bogtha ( 906264 ) on Wednesday July 22, 2009 @03:58PM (#28786611)

    AJAXing your site makes it slow.

    Nonsense. Using Ajax can slow down a site, or it can speed it up immensely. It depends on how you use it. When GMail was first launched, everybody raved about how fast it was. That was the Ajax.

    If you want a fast site, don't put anything on any page that doesn't absolutely need to be there, and have fast pipes and fast and enough servers.

    Assume you did that for Slashdot. You could then make further speed improvements by using Ajax in various places, for example so that it didn't reload a page full of hundreds of comments whenever you moderated.

  • Efficient code? (Score:3, Insightful)

    by dontmakemethink ( 1186169 ) on Wednesday July 22, 2009 @04:57PM (#28787599)
    Someone advocating more efficient coding of websites should surely take less than 12 paragraphs to do so!
  • by roc97007 ( 608802 ) on Wednesday July 22, 2009 @05:23PM (#28788055) Journal

    In my experience (having 20/5 Mbit fibre to the house) is that it's almost never the website's local content that loads slow, it's the damned ads. Let me say that again so that we're clear -- I'm sitting there waiting not for the content I was seeking to load, but for the ads that I don't want to load. I know there's work-arounds for this -- I use some of them and they do help. But Fred and Ethyl Nongeek is not going to know about ad suppression. To them the 'net is "just slow" and they don't know why.

    Making your local content lightning fast isn't going to help if your customers are waiting for unwanted content from some other website. And (grrrr....) this includes CAPTCHA! Sometimes it takes almost a half minute for the captcha image to come up, long after the rest of the login page has loaded.

    The worst example, and a sign of things to come, was when Google Ads went down awhile back and took a bunch of websites down with it, including (as I remember) Slashdot. If your page included google ads, it just wouldn't load. I don't think AJAX is going to help with that. Feel free to disagree, but be specific.

  • Slow websites ... (Score:2, Insightful)

    by SlashDev ( 627697 ) on Wednesday July 22, 2009 @05:24PM (#28788095) Homepage
    ... are slow mostly due to advertising. That being said, slow websites can also be due to: - Limited bandwidth where the site is hosted - Slow disk subsystem - Bandwidth throttling due to a large number of users

One man's constant is another man's variable. -- A.J. Perlis

Working...