Skip to content

Refactoring CSS and JS #146

@torgeirl

Description

@torgeirl

Goals

  • improve performance
  • reduce technical debt
  • enable the use of CSP

Possible solutions

  • since Trix's overall usage of JavaScript is limited, perhaps we could replace jQuery and Angular with more limited approaches such as HTMX and Alpine.js; they are also more appropriate for our update cadence

Tasks

  • eliminate the use of inline styling
  • eliminate the use of inline scripts ✔️
  • avoid use of eval() functions

Inline styling:

(* Inline styling is removed from /trix_admin/statistics.django.html, but that has caused (at least) two changes:

  1. the table header styling now has working directional arrows («A-Z indicators») 🎉
  2. the course tag has a nonfunctional X (should only be displayed on optional tags) ❌)

Inline scripts:


HTMX features that rely on eval() are:

  • event filters
  • hx-on: attributes
  • hx-vals with the js: prefix
  • hx-headers with the js: prefix

Note that all features removed by disabling eval() can be reimplemented using your own custom javascript and the htmx event model.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions