Replacing `setTimeout` Globally
A technical guide to safely overriding global `setTimeout` and `setInterval` in JavaScript, covering browser compatibility and pitfalls.
Ben Cherry is a software engineer based in San Francisco, best known for his writing on JavaScript performance and core language concepts. He shares practical insights from startup and large-scale engineering experience.
24 articles from this blog
A technical guide to safely overriding global `setTimeout` and `setInterval` in JavaScript, covering browser compatibility and pitfalls.
A defense of the hashbang (#!) in URLs, arguing it's a necessary trade-off for building rich web applications like Twitter, not a flaw in the web itself.
Explains HTML5 History API, including hashchange events, pushState, and popstate for managing browser history in single-page applications.
A developer shares key principles for writing testable JavaScript code, focusing on avoiding singletons to prevent state pollution in tests.
A guide to creating a constructor-safe spying function for unit testing JavaScript code, with examples and implementation details.
Explains how to use JavaScript's debugger statement to inspect private variables in closure-based modules, improving debugging for patterns like the Module Pattern.
Explains how JavaScript converts objects to primitives using toString and valueOf methods, covering basics, edge cases, and performance.
A developer creates a Python library to mimic JavaScript's flexible object syntax, allowing dot notation and dynamic property access.
A presentation overview on writing efficient, high-quality JavaScript code, aimed at developers with a Python background.
An in-depth guide to the JavaScript Module Pattern, covering basics, advanced techniques, and practical examples for clean code.
Analyzes the performance difference between JavaScript's strict (===) and loose (==) equality operators, finding minimal practical impact.
Explores the minimum delay for JavaScript timers like setTimeout, revealing browser-specific limits and implications for accurate timing.
A developer details the process of converting a personal blog to HTML5, covering semantic elements, CSS adjustments, and IE compatibility.
Explains the dangers of improper JavaScript global variables and introduces a tool called badglobals.js to detect them during runtime analysis.
Explains JavaScript's function-level scoping and the hoisting of variable and function declarations, using examples to clarify common pitfalls.
A tutorial on using jQuery to find and replace specific text patterns within the DOM, useful for content editing workflows.
A critique of JavaScript's 'new' keyword, exploring its confusing behavior and edge cases through code examples.
A technique to preload JS and CSS files as print stylesheets to improve page load times, with a warning about Chrome compatibility issues.
Introducing consul.js, a JavaScript logging abstraction that wraps console functions for easier debugging and cross-browser compatibility.
A historical look at JavaScript string manipulation, comparing the performance of split/join versus replace() for find-and-replace operations.