Rewrite the editor and menu without jQuery, Backbone and underscore - #180
Open
PetrDlouhy wants to merge 3 commits into
Open
PetrDlouhy wants to merge 3 commits into
PetrDlouhy wants to merge 3 commits into
Conversation
The bundle shipped jQuery, Backbone and underscore to power one staff tool. Everything they did here has a small plain-DOM equivalent, and a host page that removes its own jQuery must not get it back through the scribbler bundle: - Backbone.View becomes two plain constructors; the only Backbone.Events pieces in use (on/trigger for the editor's open event) live in the new scribbler-dom.js together with the DOM helpers. - $.post becomes fetch with a form-encoded body -- the preview and save views read request.POST, so the wire format stays the same, and the csrfmiddlewaretoken input keeps riding along in the form data. - $.animate/fadeIn/fadeOut become CSS transitions on inline styles; the stylesheet already pins the editor at height 0 and the menu off-screen. - The draft store keeps only the localStorage path: the cookie fallback compared against a never-assigned variable, so it could never restore anything. - plugins/themes.js is deleted: an AMD module from the require.js era, nothing has been able to load it since the browserify migration, and it required jQuery. Behavior verified by running the built bundle in jsdom against a real scribble fixture: boot, menu toggle/highlight, open, preview and save round-trips (body, CSRF, prefix stripping), template-error path, and the draft save/restore/discard cycle. The qunit/PhantomJS rig was not ported: PhantomJS predates fetch and sinon's fake XHR cannot intercept it, so those tests need a real headless browser to be meaningful again. Bundle size drops from 553 kB to 367 kB minified.
Every check on this repo has been unable to start for a while: the workflow asks for ubuntu-20.04, which GitHub retired in April 2025, via actions/checkout@v2 and setup-python@v2, which stopped working when the node16 action runtime was removed. Any PR (and the weekly cron) shows "no checks reported". - Workflows move to ubuntu-latest with checkout@v4 / setup-python@v5. - The python matrix becomes 3.9-3.13 and tox tests the two supported Django LTS lines, 4.2 and 5.2 (whose floor is py3.9). The suite passes on them unchanged. - One py>=3.12 fix in the tests themselves: assertEquals was removed; testUnicodeURL now uses assertEqual. - tox no longer builds the frontend assets before the python suite: the only tests that ever looked at them are the selenium class that has been @skipIf(True, 'PhantomJS was deprecated') for years, so the make steps only added an npm dependency (and PhantomJS download) to every python run. selenium stays in deps because the module still imports it. - The qunit tox env is dropped from envlist for the same reason: it needs PhantomJS, which cannot run anywhere anymore. Coverage keeps its 80% gate, now on py3.13/Django 5.2; the docs env is untouched apart from the runner.
The qunit tests could only run under PhantomJS, which predates fetch -- after the jQuery removal they could never execute the editor again, and phantomjs-prebuilt's binary download is itself a liability on modern systems. In their place, scribbler/tests/js/editor_smoke.cjs runs the BUILT bundle in jsdom against a real scribble fixture and walks the whole editor surface: boot, menu toggle/highlight, opening a scribble, the preview and save POST round-trips (form encoding, CSRF, prefix stripping), the template-error path, and the localStorage draft save/restore/discard cycle -- 34 checks. Run it with `make test-js` (builds the bundle first; needs the jsdom devDependency). phantomjs-prebuilt and browserify-compile-templates leave package.json with the rig.
PetrDlouhy
force-pushed
the
upstream-no-jquery
branch
from
August 14, 2026 06:53
9fb182d to
5cecae9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bundle shipped jQuery, Backbone and underscore to power the inline editor. Everything they did here has a small plain-DOM equivalent, and a host page that does not load jQuery itself should not have to get it back through the scribbler bundle:
Backbone.Viewbecomes two plain constructors; the onlyBackbone.Eventspieces in use (on/triggerfor the editor's open event) live in the newscribbler-dom.jstogether with the DOM helpers.$.postbecomesfetchwith a form-encoded body — the preview and save views readrequest.POST, so the wire format stays the same, and thecsrfmiddlewaretokeninput keeps riding along in the form data.$.animate/fadeIn/fadeOutbecome CSS transitions on inline styles; the stylesheet already pins the editor at height 0 and the menu off-screen.plugins/themes.jsis deleted: an AMD module from the require.js era, nothing has been able to load it since the browserify migration, and it required jQuery.make lint-js(jshint) passes. The minified bundle drops from 553 kB to 367 kB.Behavior was verified by running the built bundle against a real scribble fixture in two environments:
Two intentional behavior notes:
innerHTML, which does not execute embedded<script>tags the way jQuery's.html()did. This only affects the editing session's live preview.fetch, so it could never run this code.scribbler/tests/js/editor_smoke.cjsruns the built bundle in jsdom against a real scribble fixture — 34 checks over boot, menu, open, preview/save round-trips, the error path, and the draft cycle. Run withmake test-js(jsdom is a devDependency;phantomjs-prebuiltand its binary download are gone).The first commit here is the CI modernization from #181, cherry-picked so this PR's checks can run — git resolves the identical changes cleanly whichever merges first.