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.
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.
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.
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.
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.
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.
Trigger a link's click action with Javascript
Programmatically activating a hyperlink can trigger navigation or attached handlers when a user action is unavailable. element.click() performs the same click action on a DOM link.
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.
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.
Converting ES6 to ES5 on the command line
Transpiling ES6 JavaScript to ES5 on the command line can produce a smaller output with tsc, but missing APIs still need polyfills.
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.
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.