LoDash: isBlank and isPresent mixins

JavaScript truthiness makes 0 and "0" look blank, while _.isEmpty only fits collections. Custom _.isBlank and _.isPresent give human-friendly checks.

Haml: Generating a unique selector for an element

Haml can derive stable CSS classes and IDs from Ruby objects, making elements easy to target from JavaScript or Unpoly updates.

Javascript Compressor - compress code online for free

Reduce JavaScript source size and make code harder to read with a free online compressor for quick minification and obfuscation.

Jasmine: Spy on value properties

Jasmine spyOnProperty() fails on plain value fields; a helper can convert them into accessors so they can be stubbed or asserted in tests.

Test that an exception or error page is raised in Capybara

Capybara error-page assertions rely on the response status code and require @allow-rescue; Selenium @javascript scenarios do not support page.status_code.

Looping through iterators in Coffeescript

Modern JavaScript APIs often return iterators, and CoffeeScript cannot use for...of for them. while with iterator.next() is needed to read iterable values.

How to deal with MethodNotAllowed errors

ActionController::MethodNotAllowed errors often come from reloads or broken JavaScript links, and can be handled by redirecting back or to a fallback URL with a flash message.

Validatious 2.0 - Easy form validation with unobtrusive JavaScript

Client-side form validation in JavaScript can be concise and unobtrusive, with chained rules for required fields and email format.

IE7 not properly redrawing elements with position: relative

Internet Explorer 7 can misplace nested position: relative elements after DOM changes, leaving elements redrawn in the wrong spot. JavaScript repaint hacks or overflow: hidden may help.

How to make your application assets cachable in Rails

Rails asset URLs need fingerprints or timestamps to let browsers cache images, stylesheets, and scripts long-term without serving stale files after updates.

CoffeeScript

Imagine all the syntactical delights of Ruby and Haml for your JavaScript. You write in a nice language, but get normal JavaScript at runtime. All whilst having full access to 3rd-party JavaScript libraries (jQuery, PrototypeJS), debugging support (it becomes pure, readable JavaScript), existing support from test suites (it’s normal JavaScript) and growing support from various text editors (TextMate, Vim, Emacs).

Using Firebug Lite to inspect HTML in Internet Explorer and other browsers

Firebug Lite brings Firebug-style DOM inspection to Internet Explorer and other browsers, including older IE versions, using a JavaScript bookmarklet.

Infinitely nested hashes in Javascript (Coffeescript)

Read and write deeply nested object values without manual path checks; NestedHash recursively traverses keys and creates missing levels.

Click on a piece of text in Cucumber / Capyabra

Clicking arbitrary page text can target any HTML element with a JavaScript handler, not just links or buttons, in Selenium features.

What you need to know about Angular SEO

JavaScript-heavy Angular apps are hard for search engines to index because crawlers often ignore client-side rendering. Server-side rendering or prerendering improves crawlability and SEO.

Unobtrusive JavaScript and AJAX

AJAX-inserted content needs re-running jQuery behavior bindings; $.unobtrusive() scopes activation to new DOM nodes and activateUnobtrusiveJavascript() triggers it manually.

Manually trigger a delegated DOM event

Delegated jQuery events can be hard to fire programmatically for testing; native dispatchEvent with the right event class works better than trigger in many cases.

Writing Fast, Memory-Efficient JavaScript

JavaScript engines such as V8 are optimized for speed, but memory use still affects performance in large applications. Understanding engine behavior helps reduce browser overhead.

markbates/coffeebeans

When CoffeeScript was added to Rails 3.1 they forgot one very important part, the ability to use it when responding to JavaScript (JS) requests!

In Rails 3.1 it’s incredibly easy to build your application’s JavaScript using CoffeeScript, however if you fire off an AJAX request to your application you can only write your response using regular JavaScript and not CoffeeScript, at least until CoffeeBeans came along.

Test that a form field is visible with Cucumber/Capybara

Capybara visibility checks can assert whether a form field is shown or hidden by label, using CSS- or JavaScript-based detection.

Check whether an element is visible or hidden with Javascript

Visibility checks can differ between DOM APIs and libraries, causing elements to be misclassified as shown or hidden. jQuery, jQuery 3, and Prototype use different rules.

sstephenson/execjs - GitHub

Run JavaScript from Ruby without choosing a runtime manually; ExecJS automatically selects an available engine and returns results as Ruby objects.

6 front-end techniques for Rails developers. Part I: From big ball of mud to separated concerns

Untangling JavaScript spaghetti in Rails front ends by splitting responsibilities into separate layers without a JavaScript framework.

Unobtrusive jQuery to toggle visibility with selects and checkboxes

jQuery can show or hide form sections based on select values, radio buttons, checkboxes, blank values, and _checked or _unchecked states.