liveBook · Manning

Chapter 14: Chapter 14. Developing cross-browser strategies

What you will learn in chapter 14 of Secrets of the JavaScript Ninja, Second Edition

The introduction frames cross-browser JavaScript development as a broad challenge that requires prioritizing limited project resources.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction frames cross-browser JavaScript development as a broad challenge that requires prioritizing limited project resources.

Key terms: cross-browser JavaScript code, supported browsers, finite development resources

14.1 Cross-browser considerations

This section explains why cross-browser support requires deliberate choices and how to choose browser–platform combinations without sacrificing quality.

Key terms: browser-specific quirks, missing APIs, cross-browser support, graded browser support, browser-support matrix, grade, target audience, market share, support effort, coverage

14.1 Do you know?

This section poses self-check questions about browser inconsistencies, using code on other people’s pages, and polyfills without explaining the answers.

14.2 The five major development concerns

The section identifies the main concerns for reusable JavaScript and explains how to prioritize cross-browser work while allowing less popular browsers to degrade gracefully.

Key terms: intended audience, development resources, schedule, popular browsers, targeted audience, degrades gracefully

14.2.1 Browser bugs and differences

This section explains how to verify reusable JavaScript across supported browsers and why fixes for browser bugs must remain safe when browsers change.

Key terms: browser bugs, API differences, supported set of browsers, comprehensive suite of tests, fixes, future versions of the browser

14.2.2 Browser bug fixes

This section explains why cross-browser workarounds must account for eventual bug fixes, using a scrolling bug to show the risks of browser-specific hacks and distinguishing bugs from changes to unspecified APIs.

Key terms: browser bugs, bug work-arounds, bug fixes, scrollTop, scrollLeft, html element, body element, user agent string, specification, browser bug

14.2.3 External code and markup

This section explains how reusable JavaScript can coexist with unfamiliar page code and markup by limiting its own interference and anticipating integration hazards.

Key terms: reusable code, external code, robust, encapsulation, global footprint, namespace, global namespace, function prototypes, object properties, DOM element methods

14.2.4 Regressions

The section explains what browser regressions are, how some API changes can be anticipated, and why testing new browser releases remains essential.

Key terms: regression, non-backward-compatible API changes, feature detection, addEventListener, attachEvent, suite of tests, browser releases, regressions, browser vendors, JavaScript libraries

14.3 Implementation strategies

Introduces the need for effective, situation-appropriate strategies to build robust cross-browser code, without explaining those strategies yet.

14.3.1 Safe cross-browser fixes

This section explains how browser-independent fixes can make an API behave consistently across browsers, using two jQuery workarounds to show both a painless fix and a deliberate tradeoff.

Key terms: cross-browser fixes, browser or feature detection, height or width style properties, negative values, unified API, type attribute, injected input elements, uniform informational exception

14.3.2 Feature detection and polyfills

The section explains how to use feature detection to choose supported browser functionality, supply polyfills for missing APIs, and fall back when an application needs unavailable browser facilities.

Key terms: feature detection, object property, fallback, polyfill, Array.prototype.find, predicate function, full application functionality, reduced-experience fallback, >>>, zero-fill right-shift operator

14.3.3 Untestable browser issues

The section explains why some browser differences cannot be tested reliably at runtime and how those limits shape cross-browser code.

Key terms: event handler, event listener, bound handlers, event firing, window load, mouseenter, mouseleave, CSS property effects, color, backgroundColor

14.4 Reducing assumptions

This section shows how to make cross-browser code more reliable by questioning its assumptions while accepting that some assumptions are unavoidable.

Key terms: user-agent detection, navigator.userAgent, browser detection, event-attaching code, callable functions, binding an event, assumptions, regressions, code base

14.5 Summary

14.6 Exercises

Concepts explained in this chapter

← Chapter 13: Chapter 13. Surviving events

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.