RSJS, a guideline for non-SPA web app JavaScript structure, advocates for clear conventions to prevent the ‘jQuery soup’ anti-pattern, promotes using data attributes over classes for behaviors, and suggests maintaining JavaScript outside HTML markup for easier testing and maintenance.

Main Points

No inline scripts

RSJS advises against inline scripts to keep JavaScript maintainable and testable, suggesting external JS files for imperative code.

Think in component behaviors

RSJS promotes thinking in component behaviors, recommending one component per file for better organization.

Consider using onmount

To ensure compatibility and testability, consider using libraries like onmount for writing behaviors.

Insights

RSJS provides a structured approach for organizing JavaScript in non-SPA web applications, promoting maintainability and consistency.

This document is a collection of guidelines on how to structure your JavaScript in a standard non-SPA web application.

RSJS aims to address the 'jQuery soup' anti-pattern by promoting clear conventions for behaviors and component structure.

You will typically see Rails projects with behaviors randomly attached to classes, such as the problematic example below.

RSJS encourages the use of data attributes over classes for applying JavaScript behaviors to HTML elements, to reduce ambiguity between styles and behaviors.

It’s preferred to mark your component with a data-js-_ attribute.

Links

URL

https://ricostacruz.com/rsjs/
Hi Josh Adams, I am your personal AI. What would you like to ask about your notes?