O'Reilly logo

DOM Scripting: Web Design with JavaScript and the Document Object Model, Second Edition by Jeffrey Sambells, Jeremy Keith

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 5. Best Practices

What this chapter covers:

  • Graceful degradation: ensuring that your web pages still work without JavaScript

  • Unobtrusive JavaScript: separating structure from behavior

  • Backward compatibility: ensuring that older browsers don't choke on your scripts

  • Performance considerations: making sure that your script is performing at its best

Together, JavaScript and the DOM form a powerful combination. It's important that you use this power wisely. This chapter describes some best practices that you can use to ensure that your scripts don't do more harm than good.

Mistakes of the past

Before we get to the specifics of best practices for having web pages work correctly, let's take a quick look at some reasons that things can go wrong.

Don't ...

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