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:
- the table header styling now has working directional arrows («A-Z indicators») 🎉
- the course tag has a nonfunctional
X (should only be displayed on optional tags) ❌)
Inline scripts:
To ease the transition from Angular/jQuery to HTMX, the json-enc extension has been used. Ideally, we shouldn't need to pass JSON to the backend but rather handle parameters in regular URL format. ❌
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.
Goals
Possible solutions
Tasks
eliminate the use of inline scripts✔️eval()functionsInline styling:
✔️trix/trix_admin/templates/trix_admin/assignments/preview.django.html✔️trix/trix_admin/templates/trix_admin/editor/markdown_help.django.html✔️trix/trix_admin/templates/trix_admin/roleselect.django.html✔️*trix/trix_admin/templates/trix_admin/statistics.django.html+../include/progress_bar.django.html✔️trix/trix_course/templates/trix_course/add_course_admin.django.html✔️trix/trix_course/templates/trix_course/course_admin.django.html✔️trix/trix_student/templates/trix_student/assignment_list_base.django.html✔️ (removed)trix/trix_student/templates/trix_student/consent_form_base.django.html✔️trix/trix_student/templates/trix_student/include/assignment.django.html(* Inline styling is removed from
/trix_admin/statistics.django.html, but that has caused (at least) two changes:X(should only be displayed on optional tags) ❌)Inline scripts:
✔️trix/trix_admin/templates/trix_admin/statistics.django.html✔️ (removed)trix/trix_student/templates/trix_student/assignment_list_base.django.htmlTo ease the transition from Angular/jQuery to HTMX, the
json-encextension has been used. Ideally, we shouldn't need to pass JSON to the backend but rather handle parameters in regular URL format. ❌HTMX features that rely on
eval()are:hx-on:attributeshx-valswith thejs:prefixhx-headerswith thejs:prefix