John Cox

Blogs · @wyome

Tagged performance · everything

Why do big websites (e.g., Facebook) use a separate domain to host their resources? : webdev

This explains why major sites like Facebook use separate domains to serve static content: sending cookies with every HTTP request wastes significant bandwidth, especially on mobile connections where upload speeds are slow relative to download speeds. The cookieless domain approach lets sites avoid transmitting cookies for requests that don't need them, while CDNs provide additional benefits like serving content from geographically closer servers and letting browsers cache popular libraries across multiple websites.

Permalink

Isomorphic JavaScript: The Future of Web Apps - Airbnb Engineering

Single-page JavaScript apps offer great user experience and clean separation between client and server, but suffer from SEO problems, slow initial page loads, and duplicated logic across languages. Airbnb proposes "isomorphic JavaScript"—code that runs on both server and client—to get the performance and SEO benefits of server-rendered HTML while maintaining the interactivity of client-side apps, enabled by Node.js and libraries like their open-source Rendr framework. This hybrid approach requires solving several abstraction challenges around routing, data fetching, view rendering, and build tools, but promises to become standard practice as more teams adopt Node.js in production.

Permalink

Chrome Web Store - Clockwork

Clockwork is a browser extension that integrates directly into your developer tools to provide real-time insights into PHP application performance and behavior, displaying request data, database queries, cache operations, log entries, and other runtime metrics without leaving your browser. The tool requires installing a server-side component via Composer and offers first-class support for Laravel applications as well as vanilla PHP setups. The developer does not collect or share user data, and the extension is designed with privacy as a core principle.

Permalink

PHP Image Cache

This PHP class compresses and caches images in a user's browser to dramatically reduce page load times—in the demonstrated example, image load time dropped from 2.19 seconds to 23 milliseconds, a 98.95% improvement. The implementation is straightforward: you include the class, optionally set a cache directory, and pass image paths to the cache method, which returns a new source URL to use in image tags. The tool can be installed manually or via Composer and is open to community contributions.

Permalink

Magnific Popup: Responsive jQuery Lightbox Plugin

Magnific Popup is a lightweight jQuery lightbox plugin (now deprecated) that displays images and content in responsive popups with a focus on performance and mobile compatibility. The plugin uses CSS for content resizing rather than JavaScript, supports high-DPI displays, and includes features like lazy-loading, zoom effects, and conditional lightbox switching for mobile devices. The author recommends using the native HTML `<dialog>` element for basic modals or PhotoSwipe for advanced image galleries as alternatives.

Permalink

PHP DebugBar

PHP DebugBar is a development tool that displays browser-based diagnostics replacing manual var_dump() calls, showing performance metrics, errors, request data, and SQL queries across PHP projects. It integrates with major frameworks like Laravel, Symfony, and Drupal while remaining framework-agnostic through middleware support, and includes built-in collectors for common libraries like PDO, Monolog, and Twig. The tool is strictly for development environments and offers a clean JavaScript interface with the ability to save and replay previous requests.

Permalink

Deep dive into the murky waters of script loading - HTML5 Rocks

This article explains the various ways to load JavaScript in browsers and their tradeoffs, from simple script tags to complex techniques leveraging browser quirks. The author maps out how different script-loading methods (plain tags, defer, async, dynamically-created scripts with async=false) behave across browsers and parsing states, showing that each approach makes different compromises between blocking rendering, controlling execution order, and triggering parallel downloads. The practical conclusion is pessimistic: HTML offers no way to simultaneously avoid blocking rendering, load scripts in parallel, and guarantee execution order without either repetition or JavaScript complexity, so most developers should simply place script tags at the end of the body.

Permalink

jQuery Unveil - A very lightweight plugin to lazy load images

Unveil is a lightweight lazy-loading plugin for jQuery that defers image loading until they enter the viewport, reducing page load times on long pages. It uses data attributes to specify actual image sources and supports retina display optimization through a separate high-resolution image attribute, all in under 1KB. The plugin offers customizable loading thresholds, callback animations, and manual triggering options while maintaining fallback support for users without JavaScript enabled.

Permalink

5 HTML5 Features you need to know – Adnane Belmadiaf's Blog

This post surveys practical HTML5 features that improve web application performance and reduce development overhead, including DNS prefetching to speed up domain resolution, link prefetching and prerendering to load anticipated content in advance, the download attribute to trigger file downloads without server-side code, pattern validation for form inputs using regular expressions, and the datalist element for autocomplete functionality without requiring jQuery or database queries. The examples demonstrate how these built-in capabilities eliminate common workarounds and dependencies that were previously necessary for basic web app functionality.

Permalink

Untitled (http://www.html5rocks.com/en/tutorials/workers/basics/)

Moving computationally intensive work off the main thread using web workers can make web apps feel more responsive across devices of varying capabilities, even if total execution time doesn't improve. While web workers have historically been awkward to use due to message-passing complexity, libraries like Comlink abstract away this difficulty and allow developers to separate concerns like game logic from UI rendering, ensuring that user interactions receive timely main-thread attention. The off-main-thread approach trades raw speed for reliability and perceived responsiveness, particularly benefiting constrained devices where a frozen interface is worse than a slow but continuously updating one.

Permalink

Appcache Facts

AppCache was introduced in HTML5 as a simple declarative solution for offline web capability, but its rigid design created numerous frustrating problems: cached content wouldn't update until the next page load, a single failed file would invalidate an entire cache, and unlisted files couldn't load even with an active internet connection. These fundamental limitations—particularly documented in Jake Archibald's 2012 critique—taught the web standards community that declarative caching models were too inflexible for real-world needs, leading to the development of Service Workers, which use JavaScript to give developers imperative control over caching and networking logic and now form the basis of Progressive Web Apps.

Permalink

Tools, tips and links on optimizing mySQL | drupal.org

This guide provides practical MySQL optimization techniques for Drupal sites, covering configuration file tuning, appropriate storage engines (InnoDB over MyISAM for write-heavy tables, Archive for append-only logs), and tools for identifying performance bottlenecks like the MySQL Performance Tuning Primer Script and MySQLTuner. It includes sample my.cnf configurations scaled for different RAM allocations and recommends focusing optimization efforts on slow query logs, proper thread caching, and table maintenance routines like OPTIMIZE TABLE.

Permalink

What to tune in MySQL Server after installation - MySQL Performance Blog

Percona Server for MySQL 9.7.2-2 introduces native DISTANCE() and VECTOR_DISTANCE() functions that enable vector similarity calculations directly within SQL queries, supporting multiple distance metrics including cosine, Euclidean, Manhattan, and dot product scoring. This addition allows developers to perform vector-based operations—essential for AI and machine learning applications—without requiring external specialized databases or complex workarounds.

Permalink

5 Tips for More Efficient jQuery Selectors - SitePoint

This guide explains how to write faster jQuery selectors by leveraging browser capabilities and understanding how jQuery's selector engine works. Key strategies include preferring ID selectors over class selectors, qualifying class selectors with tag names, keeping selectors simple rather than deeply nested, structuring selectors to start with the most specific elements, and avoiding redundant selector calls through chaining or caching. The article emphasizes that older browsers lack native support for complex CSS selectors and must use jQuery's Sizzle engine to manually parse and search the DOM, making optimization particularly important for cross-browser compatibility.

Permalink