Fixing flaky E2E tests

E2E tests often fail from race conditions between browser, app, and test script; synchronizing actions, retries, and test environment settings improves stability.

Asset pipeline may break Javascript for IE (but only on production)

JavaScript can break in Internet Explorer only after Rails asset compression in staging or production. Switching from UglifyJS to YUI Compressor can avoid these failures.

Pierce through Javascript closures and access private symbols

Accessing state hidden in JavaScript closures can simplify tests and let Jasmine spies mock private methods or inspect local variables.

How to create giant memory leaks in AngularJS (and other client-side JavaScript)

AngularJS client-side code can steadily accumulate unreclaimed objects until the browser process crashes. Common causes include forgotten listeners, timers, plugins, scopes, and unbounded caches.

JavaScript: How to check if an object is NaN

NaN is difficult to compare in JavaScript because it never equals itself. Object.is() works in ES6; ES5 needs a number type check plus isNaN().

Compiling Javascript template functions with the asset pipeline

Compile .jst templates into JavaScript functions via the asset pipeline for rendering with JST[...], including EJS and Eco templates.

How to human-join an array in JavaScript

Human-friendly list formatting in JavaScript is awkward; joinSentence produces an Oxford-comma sentence from array items, similar to Rails to_sentence.

Detecting when fonts are loaded via JavaScript

Webfonts can change layout after first render; detecting readiness avoids wrong measurements. Modern browsers use document.fonts.load, while older support needs font-dimension watching.

JavaScript: How to log execution times to your browser console

Measure JavaScript code duration in the browser with console.time and console.timeEnd, including asynchronous flows and separate code locations. Works in modern browsers and recent Internet Explorer.

Browser debugging tricks

Useful browser devtools techniques for finding tricky JavaScript bugs, inspecting calls, and pausing execution on changes to state, URLs, or DOM properties.

Minified JavaScript and CSS

Production assets should be minified for faster delivery and smaller payloads. Rails 3.1+ handles this through the asset pipeline; older Rails versions need compressed JavaScript libraries.

Minify Font Awesome fonts with webpack

Reduce Font Awesome icon font size by subsetting unused glyphs with fontmin-webpack, keeping low CPU usage and no JavaScript while avoiding oversized font downloads.

JavaScript: Hash/Object with default value

Use Proxy to make a JavaScript object return a default value for missing properties instead of undefined, for modern browsers only.

The Plight of Pinocchio: JavaScript's quest to become a real language - opensoul.org

JavaScript has become essential for production applications, but maintainable code still depends on structured design, object-oriented principles, and test-driven development.

Managing vendor libraries with the Rails asset pipeline

Rails asset pipeline issues make vendor libraries hard to keep separate; custom asset paths and rewritten font URLs preserve clean library folders and correct references.

Defining new elements for your HTML document

Custom elements let you create semantic HTML components that browsers render normally and activate directly with customElements.define(), avoiding framework-specific compilation.

simple_format helper for Javascript

Rough JavaScript equivalent of Rails simple_format for turning plain text into HTML paragraphs and line breaks. Whitespace preservation is not included.

Rails 3.1 error message: Could not find a JavaScript runtime

Fresh Rails 3.1 apps can fail on boot when ExecJS cannot locate a JavaScript runtime, and adding a runtime gem to the Gemfile removes the error.

Testing for XSS in Markdown Fields

Markdown fields can become XSS sinks when user input is rendered unsafely, allowing javascript: links, image event handlers, and filter bypasses.

TodoMVC - A common learning application for popular JavaScript MV* frameworks

Choosing a JavaScript MV* framework is difficult when options look similar; TodoMVC provides the same Todo app across popular frameworks for side-by-side comparison.

Cucumber: Detect if the current Capybara driver supports Javascript

Capybara.javascript_test? checks whether the current driver supports JavaScript, helping feature tests switch behavior for Selenium, capybara-webkit, Poltergeist, and custom drivers.

JavaScript bookmarklet to click an element and copy its text contents

Click any page element to capture its text or input value, highlight the target, and copy the cleaned content through a browser prompt.

What `var` actually does in Javascript

Undeclared assignments in Javascript often create or reuse globals instead of local variables, causing scope leaks and hard-to-track bugs.

Keeping web applications fast

Fast web apps avoid unnecessary database work, oversized assets, and heavy client-side rendering, while measuring bottlenecks before optimizing caches, scripts, images, or page delivery.