Skip to content

Fetch Dropzone after the first paint on the upload pages, and serve it minified (#63, stacked on #314) - #324

Open
r0ny123 wants to merge 53 commits into
masterfrom
perf/load-dropzone-after-first-paint
Open

r0ny123 wants to merge 53 commits into
masterfrom
perf/load-dropzone-after-first-paint

Conversation

@r0ny123

@r0ny123 r0ny123 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #314 (and so on #313, #304, #245 and #126). Merge those first; until then this diff also shows their commits. This PR's own commits are af8f8f8 and 09c43d9, the merge of master (e7e75fa), and three after it: b7c33a5 (queue the search as you type after the first paint: the live_search.js tags on the four listing pages use later()), e9c3d98 (hold back the minified Dropzone in the zone-width test) and 52a9485 (regenerate the icon subset for master's new fa-key and fa-triangle-exclamation), then the merge of #314's new head with master 8fd5a8c (9f5de86).

Part of #63. #126 fetches Dropzone on the first drag on every page that only carries the drop overlay. The query, submit and import pages, whose content the drop zone is, still load it with a script tag in the body. Its 77 KB (gzipped) share the network with what the page is painted from, and running it counts as blocking time.

Change.

  • af8f8f8: queue Dropzone after the first paint.
    • On those pages Dropzone is queued with later(), as ADR-0021 asks of a page's own library. That is done from submit_or_query_dropzone_js() (table/submit_or_query_dropzone.html:19-:20) and from import.html's {% block style %} (:12-:13). Their script tags are gone.
    • static/dropzone_attach.js is queued right behind it. It turns auto-discovery off and attaches #myDropzone with the options flask-dropzone renders. The templates park those options in window.mcritDropzoneOptions instead of assigning them to Dropzone.options.myDropzone, because Dropzone is not there yet when they are read. This is how Trim the page weight: page-specific libraries, minified CSS, deferred Bootstrap, lazy Dropzone, gzip (#63) #126's loader attaches the overlay's form.
    • Unlike the overlay's form, the page's form keeps its dropzone class, and so its look, from the first paint. Auto-discovery cannot attach it first. Run after DOMContentLoaded, Dropzone's contentLoaded() waits for the document to be complete (static/dropzone.js:10438), and the scripts the queue adds hold that back until they have run. Once the document is complete it registers nothing at all. ADR-0015 says a late dropzone.js "discovers immediately" once readyState is complete, but the vendored code does not. The test below checks the options the zone ends up with either way.
    • upload_form.js is unchanged. Its ready handler runs mcritInitDropzone() on a form without data-lazy (:206), after the queue, by which time the zone is attached.
  • 09c43d9: serve Dropzone minified, written from the patched dropzone.js.
    • Compiling the 343 KB source was most of Dropzone's task after the first paint.
    • scripts/minify_dropzone.py writes static/dropzone-patched.min.js from static/dropzone.js with rjsmin 1.3.0. That is a pure-Python minifier that strips comments and whitespace and renames nothing.
    • The output is 221 KB, or 51 KB gzipped against 77 KB. Its header keeps the licence notices the comments carried: Dropzone's, and those of the contentloaded.js and core-js it bundles.
    • The upload pages and Trim the page weight: page-specific libraries, minified CSS, deferred Bootstrap, lazy Dropzone, gzip (#63) #126's overlay loader load it. dropzone.js stays the file to edit: change it, then run the script.
    • The stock dropzone.min.js is still unpatched and still unused.
  • AGENTS.md's front-end rule names Dropzone among the libraries queued with later(), and says how its options reach it. Its dropzone bullet says which file the pages load and how it is written.

Verification.

Lighthouse 13.5.0, mobile, against the captured corpus, signed in as a contributor. Performance is given per run, the other metrics as means.

af8f8f8 against #314's head (239372c), three runs a side, the sides in turn:

page Performance FCP LCP TBT CLS
/analyze/query 94/94/94 -> 97/96/97 1.57 -> 1.56 s 2.80 -> 2.34 s 125 -> 113 ms 0.000 -> 0.000
/data/submit 95/96/94 -> 98/98/98 1.35 -> 1.39 s 2.63 -> 2.17 s 141 -> 120 ms 0.000 -> 0.000
/data/import 96/95/95 -> 96/97/96 1.50 -> 1.50 s 2.77 -> 2.32 s 47 -> 140 ms 0.000 -> 0.000

The largest paint is the phone-width navbar logo. It no longer shares the network with the library, and it comes 0.45 to 0.46 s earlier. Running Dropzone was then still one long task, 105 to 221 ms at Lighthouse's CPU slowdown, 43 to 97 ms of it compiling. It comes after the first paint now, where Lighthouse counts it as blocking time. Before, on the import page, it ran while the page parsed, where it was not counted. That is why that page's blocking time went up and its score stayed where it was.

09c43d9 against af8f8f8, on a build of all open PRs with this branch merged, three runs a side:

page Performance TBT Dropzone's script time (of it parse and compile)
/analyze/query 88/99/100 -> 100/100/99 210 -> 81 ms 128-371 -> 93-98 ms (51-124 -> 27-30 ms)
/data/submit 92/98/97 -> 99/98/100 232 -> 117 ms 179-269 -> 135-161 ms (65-97 -> 42-50 ms)
/data/import 100/100/99 -> 100/100/100 66 -> 53 ms 112-137 -> 97-135 ms (46-49 -> 30-45 ms)

FCP, LCP and CLS are unchanged there (1.09-1.10 s, 1.26-1.28 s, 0). Before this commit, that build already scored 100 on desktop on all 32 pages measured. On mobile it scored 100 on every page but these three, apart from occasional 99s on two result pages, from a headless timing artifact (the first paint is reported about a second after load). The remaining one-point dips on the upload pages are blocking time from Dropzone's evaluation and jQuery's ready handlers.

The drop zone works as before:

  • The query and submit pages' form is attached with autoProcessQueue: false.
  • mcritInitDropzone() binds the submit button and the pre-fill to it as before. The pre-fill itself, a dropped SMDA report sending its head, is covered by test_a_dropped_file_sends_its_head_for_the_pre_fill, now against the minified file.
  • The import page's status line still follows the upload, its init coming from the parked options.

Master 8fd5a8c is merged in through #314's new head (9f5de86), whose one conflict, the later() calls below master's dropzone.style() line, keeps this branch's calls; it needs no adaptation commit of its own, since b7c33a5, e9c3d98 and 52a9485 already carry what master's PRs ask of it.

Tests.

  • tests/testDropzoneBrowser.py::test_an_upload_page_fetches_dropzone_after_its_first_paint_and_attaches_it_once[/analyze/query|/data/submit|/data/import] runs in Chromium. It checks that:

    • Dropzone's request starts after the first-contentful-paint entry;
    • one Dropzone is attached, with the page's 100,000,000 MB cap rather than the default 256, and auto-discovery is off;
    • the page has no layout shift from its first paint until two frames after the queue has run;
    • on the import page, its own sending handler writes the status line;
    • there is no page error.

    On Move the upload form's and the type-ahead's scripts into static files (#63, stacked on #313) #314's head it fails on the first check on all three pages. With dropzone_attach.js emptied it fails because no Dropzone is attached.

  • tests/testAssetDiet.py:

    • ::test_the_upload_pages_queue_dropzone_and_attach_it_with_their_options replaces test_the_upload_pages_load_dropzone_up_front. It checks: no Dropzone script tag; dropzone_attach.js queued right after the patched Dropzone; the stylesheet still linked; the form still a dropzone; the options parked. ::test_the_attach_file_attaches_before_auto_discovery_with_the_parked_options reads the file.
    • ::test_the_minified_dropzone_is_the_patched_source_minified fails when dropzone-patched.min.js is not what the script writes from dropzone.js today. It skips where rjsmin is missing, so CI now installs rjsmin==1.3.0.
    • ::test_the_minified_dropzone_keeps_the_patch_and_the_notices runs without rjsmin. It checks that the patch's helpers and field are in the file, that the three licence notices are in its header, and that the file is under 70% of the source.
    • ::test_no_template_loads_the_unminified_dropzone.
  • tests/testDeferredJqueryBrowser.py::test_the_upload_page_wires_its_form now holds that the query page has one Dropzone with its options. Queued after jQuery, Dropzone attaches its $.fn.dropzone plugin there too, as on the overlay.

  • tests/testParseTimeScripts.py: Dropzone is no longer a plain script on any page, so its jQuery exemption goes, and test_dropzone_is_not_a_plain_script_anywhere holds that.

  • tests/testUpload.py reads the import page's options from window.mcritDropzoneOptions.

The suite passes on this branch (2872 tests).

Relation to open PRs. On a build of all open PRs this merges with conflicts in three places:

r0ny123 added 30 commits August 30, 2026 04:44
Issue #63, first bullet: "remove data-tables js/css once it is not needed
anymore". base.html loaded 623 KB of render-blocking JavaScript and 41 KB of
CSS on every page in the app, for two calls.

DataTables is removed outright, not moved. Its one initialiser selected
`#job-table`, and the jobs page renders its table with `table_id=active` -
the job method - so the selector matched nothing on every request. Confirmed
against the running app: `id="job-table"` appears in zero of /data/jobs,
?active=..., ?state=... and /. It was also configured with paging, searching
and info all off, so even where it had matched it would only have restyled
the table.

jQuery UI moves to result_cross.html, the only page that calls `.sortable()`.
{% block style %} runs after base.html's scripts, so jQuery is in place first.

Measured with Chromium, total decoded bytes per page:

    /                     1667 KB -> 1017 KB
    /explore/samples      1667 KB -> 1017 KB
    /data/jobs            1667 KB -> 1017 KB
    /data/result/<cross>  1691 KB -> 1595 KB   (keeps jQuery UI)

Behaviour is unchanged: `.sortable()` still applies on the cross compare, the
clipboard tooltips still get Bootstrap instances rather than jQuery UI's -
both libraries define `.tooltip()`, and removing jQuery UI makes which one
wins deterministic rather than a load-order race - and no page logs a console
error.

Deliberately not done: `defer` on the remaining scripts, and removing jQuery.
Both need an audit of 23 inline blocks and 36 onclick handlers, several of
which call functions declared at the top level of those blocks; that is a
separate change. The remaining majority of the render-blocking weight is CSS,
not JS - bootstrap.css alone is 196 KB and is the unminified build.
Every unit job on every Python version fails with:

    /opt/hostedtoolcache/Python/3.11.16/x64/bin/python: No module named pytest

The Makefile said "pytest and pytest-cov arrive with mcrit, so requirements.txt
covers both". mcrit declares them under its `dev` extra:

    $ python -c "import importlib.metadata as m; print(m.requires('mcrit'))"
    ... 'pytest; extra == "dev"', 'pytest-cov; extra == "dev"' ...

so a plain `pip install -r requirements.txt` does not bring them in, and the
suite has not actually run in CI since mcrit moved them there. Ruff is green
throughout, which is why this looked like a working pipeline.

Installed in the workflow rather than added to requirements.txt: neither is a
runtime dependency and a deployment should not get them. Pinned, for the same
reason the lint job pins ruff. The two stale comments that said otherwise are
corrected.
`init` still ran `pip install -r requirements.txt` alone, so a fresh checkout
that follows the README lands without pytest and `make test` fails with
"No module named pytest" - the same failure the CI change on this branch fixes
for the runner, left unfixed for a contributor.

pytest and pytest-cov are not runtime dependencies and are not in
requirements.txt; mcrit declares them under its `dev` extra, which nothing
here requests, so they do not arrive transitively either. Install them from
`init`, pinned to the versions CI uses, and say so once above the target
rather than in a comment further down that describes a step that never ran.

Reported by Codex review.
…rst one was safe

The previous commit did #63's first bullet. The other four are "consider", "enable
text compression" and "what to inline"; a recorded, measured decision is the
resolution for those, so ADR-0015 makes them. Numbers first, all from Chromium
driving the app over real HTTP against the captured corpus.

  * text compression is the largest win left, and it is not ours. Nothing is
    compressed anywhere: Flask's static handler does not, and neither does the
    reference deployment - nginx.conf, mcritweb_plain.conf and mcritweb_ssl.conf in
    danielplohmann/docker-mcrit at 7e9501a carry no gzip directive, and location /
    proxies /static/ straight through. Simulating `gzip on;` in front of this branch,
    cold Fast-3G load of /, median of 7: first paint 3872 ms -> 1024 ms, wire
    1,069,548 B -> 354,002 B. That is more than the whole of the first bullet, and it
    belongs in docker-mcrit.

  * lazy dropzone: right target, wrong shape today. dropzone.js is 353,924 B, 38% of
    every page, but it loads at the end of <body>, so blocking it outright - an upper
    bound - moves first paint by 8 ms. It buys DOMContentLoaded (1585 -> 1009 ms) and
    23% of the transfer. The cost is Flask-Dropzone: dropzone.config() emits
    Dropzone.options.myDropzone *after* the library and only works because discovery
    waits for DOMContentLoaded. Injected late, contentLoaded() sees readyState
    "complete" and binds the element with default options - no CSRF header, no
    autoProcessQueue: false. Doing it right means replacing create()/config() by hand
    in the one place static/dropzone.js's local patch has to keep working.
    "autocomplete on mouseover" is 4,621 B, 1,507 gzipped: no.

  * removing jQuery: no. 15 of 26 inline blocks call $, 36 inline event attributes
    hang off them, trace_CFG/main.js and main_duo.js expect it from base.html, jQuery
    UI cannot load without it, and .tooltip()/.modal() go through Bootstrap's jQuery
    bridge. 89,503 B, 30,882 gzipped - under 9% of a compressed page.

  * inline vs reference is already right: 7,141 B of inline JS against 902,940 B of
    referenced library. The remaining CSS weight (bootstrap.css is the unminified
    build) compresses 8x, so gzip answers that too.

ADR-0004 asked #63 to assert rather than assume which library owns $.fn.tooltip, and
called the current arrangement a load-order race. Measured, it is not one. Bootstrap
5.0.2 defines its jQuery plugins on DOMContentLoaded, after every plain <script> in
the document, so it wins the name in both arrangements - jQuery UI before it, as
base.html used to, and after it, as result_cross.html now does. Checked on every page
that renders a [data-toggle="tooltip"] target: $.fn.tooltip.Constructor.NAME is
"tooltip", bootstrap.Tooltip.getInstance(el) is set, $(el).data("ui-tooltip") is not.
What does flip it is loading jQuery UI *after* DOMContentLoaded, which is exactly what
a lazy loader would do - so the hazard is lazy loading, not ordering.
test_bootstrap_is_loaded_synchronously pins that.

The one factual correction: the previous commit said DataTables' initialiser "selected
an element the app never renders". The app does render id="job-table" - job_table
still defaults to it and job_overview and single_sample take the default, confirmed on
/explore/samples/1. What made DataTables dead is narrower: the initialiser lived on
the jobs page, which passes table_id=active. The removal stands; the reason in the
comments and the test docstring did not, and now says what was measured.

New tests, each mutation-checked by breaking the code it guards:

  TestTheJobsPage             - none of the three jobs views renders id="job-table"
  TestTheCrossComparePage     - the rendered page ships jquery-ui, jquery.js reaches
                                it first, and no other page ships it at all
  test_only_base_html_loads_a_jquery      - both CFG templates' second jQuery stays
                                            commented out
  test_bootstrap_is_loaded_synchronously  - no defer/async on the bundle

code_of() now strips HTML comments as well as Jinja ones, which is what makes the
second-jQuery check see the commented-out includes as absent rather than present.
…zone, gzip

Font Awesome is reduced to the icons the templates use, Bootstrap ships
minified and deferred, the Dropzone script and stylesheet load on the first
drag or on opening the modal, and responses over 1 KiB of compressible types
leave gzipped (MCRITWEB_COMPRESS_RESPONSES turns it off behind a proxy that
compresses itself).
ADR-0015 had left compression to the proxy and the other bullets to a later
audit. Both happened; 0015 is marked superseded and 0016 holds the
measurements and the rules that follow from them.
The type-ahead conflicts are the ones that matter. This branch's side of
js/ac_family_names.html and the submit dropzone still carried the old
family-name code - names shipped with |tojson and pushed unescaped into a
widget that renders suggestions through innerHTML, which is the injection
master closed in #168 (and #146 moved to a JSON endpoint). Master's
escaped code is kept in both places; what this branch contributes there
is only its reason to change them, that Bootstrap is now deferred, so the
widgets are built once the deferred scripts have run. In
ac_family_names.html the DOMContentLoaded listener is also the scope,
replacing master's IIFE, so this branch's timing test can see it. The
Playwright tests that drive the real widget pass with Bootstrap deferred.

The rest:
- base.html: the minified Bootstrap and the Font Awesome subset, with
  master's signed-in font preload (#62) - the subset loads the same
  ../webfonts/fa-solid-900.woff2 the preload names; Bootstrap and
  post_action.js deferred, page_loading.js kept a plain script as master
  has it; clearDropzone keeps the lazy-load guard with master's const.
- the dropzone keeps mcritInitDropzone(), with master's const myDropzone
  (#61) - nothing outside that function uses it.
- import.html takes master's import status script, with dropzone.min.js.
- README keeps the compression paragraph and master's reverse-proxy
  section.
- the Font Awesome subset is regenerated for three icons master's
  templates added (arrows-rotate, code, diagram-project), nothing else
  changes in it; the subset script lists the webfont file stems as
  non-glyphs, since master's preload and its comment name
  fa-solid-900.woff2 and the icon scan read that as an icon.

1026 passed, ruff clean.
autocomplete.js and page_loading.js were plain scripts in <head>, so they
blocked first paint although nothing calls them while the page parses:
page_loading.js only registers event listeners, and every `new Autocomplete`
already waits for DOMContentLoaded, which fires after all deferred scripts
have run. Both are now deferred alongside Bootstrap and post_action.js.
jQuery stays a plain script because inline blocks call `$` while parsing.
The single function and function comparison pages loaded d3, graphlib,
graphlib-dot, dagre-d3 and convexhull.js as plain scripts in <head>, about
120 kB gzipped (390 kB raw) that held back the first paint although
nothing uses them before the CFG scripts at the end of the page and
window.onload. They now load immediately before main.js / main_duo.js, in
the same order, so every script that uses them still runs after them.
Lighthouse's desktop run of the comparison page no longer lists them as
render-blocking.
/help shows 21 screenshots, about 2 MB, and the browser fetched all of
them on load, so the first one - the page's largest contentful paint -
shared the connection with twenty images below the fold. Every screenshot
after the first now carries loading="lazy". The first stays eager:
lazy-loading the largest paint element would delay it.
With loading="lazy" and no width or height, a screenshot is a 2px placeholder
until it arrives. The browser scrolls to /help#jobs-queue, the screenshots now
in view load and grow, and the heading ends up 4,782px below the window (1400x900)
and stays there. Every section link past the first few screenshots missed.

manual.py reads each PNG's size from its header and writes it on the <img>.
With height: auto in style.css the space is reserved before the image loads,
and the image still scales down with the column. Every anchor now lands at the
top of the window, at 1400x900 and 800x700, and only the screenshots in view
download.
…libraries

Master replaced the family names shipped with each page by a type-ahead that
fetches them as they are typed (#192), and the submit dropzone now includes
js/ac_family_names.html instead of building its own list. Kept master's
widget and this branch's reason to touch it: Bootstrap is deferred, so the
widgets are built in a DOMContentLoaded listener rather than master's IIFE.
The dropzone macro takes master's signature without `families` and keeps
`lazy`, which base.html's overlay still passes.
The lazy loader, the query and submit pages and the import page loaded
static/dropzone.min.js, which is stock Dropzone 5.9.2. Only dropzone.js
carries the patch that sends the head of a dropped file, so a drop posted
no file_header and the submit form was no longer pre-filled. All three
load dropzone.js again; dropzone.min.js is the retired file now.

A failed fetch of the script left mcritDropzoneLoading set, so the overlay
never opened again on that page. It is cleared on error, and the next drag
tries again without adding a second stylesheet. A dragover while the
script is on its way no longer queues the same callback again. The two
URLs go into the script through |tojson.
send_file answers If-None-Match against the plain ETag before the
after_request hook renames it, so a client revalidating its gzipped copy
never matched and downloaded every asset again. The conditional check is
made again against the renamed ETag.

HTML is no longer compressed. A page carries the session's CSRF token, the
same in every response, next to input it reflects, which is what a BREACH
attack needs. Downloads, the /api passthrough, bodies of unknown length
and bodies over 1 MiB are left alone too: the exports and the cached
result download are streamed so that they never sit in memory whole, and
reading them in to gzip them undid that.

gzip;q=0 is a refusal; request.accept_encodings reads it as one. The
README said docker-mcrit's NGINX compresses; its configuration has no
gzip directive (ADR 0015).
…irect in its test

Master's templates now use fa-pen, which the Font Awesome subset did not carry, so
scripts/subset_fontawesome.py is rerun. /data/jobs now redirects to the URL that
names its first tab, so the DataTables id check follows the redirect to the page
that is actually rendered.
Batch C brought master docs/adr/0016-slow-function-search-is-mcrits.md,
so this branch's 0016 shared the number. The record moves to 0017 and
ADR-0015's status line points at it; nothing else names the file.
jQuery was the one script in every page's head that still held back the
first paint: inline blocks called $ while the page parsed, so 0017 left it
a plain script. base.html now defines whenReady(fn), which waits for
DOMContentLoaded and hands fn to jQuery, so ready handlers keep the timing
and order they had. The 21 parse-time uses of $ in 15 templates, and the
settings page's Sortable calls, run from it, and jQuery, jQuery UI and
SortableJS are deferred. Bootstrap loads below {% block style %}, so that it
still owns $.fn.tooltip over jQuery UI on the cross compare.

Between the first paint and DOMContentLoaded a click can now reach a page
whose jQuery has not run:
- the pickers' search forms are bound to document while the page parses,
  so an early Enter keeps the selection and the settings;
- fetchState reads its checkboxes and deleteSample finds its row without
  jQuery;
- the sample list's Analyze flag starts cleared;
- the upload radios leave their fields to the ready handler, which now
  also shows them for SMDA;
- the navbar's Analyze and Data menus link to "#" instead of reloading
  the page.

ADR-0018 records the audit, the rule for templates and what it costs.
testParseTimeScripts fails on a parse-time use of anything a deferred
script defines, and testDeferredJqueryBrowser drives the pages with
jquery.js held back.
With #304 jQuery, post_action.js, page_loading.js, the type-ahead, a
page's own jQuery plugins and Bootstrap are deferred, but a deferred
script is still fetched at once, alongside the stylesheets the page is
painted with. base.html now queues them with later() and loads the queue,
in order, once the browser reports the first contentful paint, with a
fallback for browsers without paint timing, at once for a page that is
not visible, and a backstop three seconds after DOMContentLoaded.
whenReady runs its functions once the queue has run, and at once after
that. A click on a Bootstrap control or a data-post button before then is
held and made again; a tooltip toggle is not, since a tooltip acts on
hover and focus. csrfToken() moves into base.html's first script,
since the CFG viewers call it from window.onload. The upload form's ready
handler sets its fields instead of sliding them, and the copy buttons
copy before the queue is in and confirm once it is. ADR-0021 records it.
test_the_queue_is_fetched_once_the_page_has_been_painted sorted the
scripts' resource entries by startTime and compared that with the queue.
The browser does not have to start the requests in the order the scripts
were added: on a branch that queues two more scripts it started one ahead
of another queued before it, in one run of six under load, and the test
failed. What the queue does promise is the order the scripts run in
(async = false), and the old assertion did not hold that: with async set
to true it still passed in two runs of three.

The test now records each script's load event, which fires once the
script has run, and compares that order with the queue. The requests are
still checked to be the queued scripts and to start after the first
paint.
Every page carried the drop overlay's upload form code and the family
type-ahead inline, about 10 KB of HTML, and a listing page the type-ahead
twice. That put the settings page, which is sent uncompressed for its API
token, a round trip later, and the larger result pages too.

They are static/upload_form.js and static/family_names.js now, queued
with later(), which queues a file once however often a page includes its
partial. What only the template knows reaches them as data- attributes
on the form, or as mcritFamilyNamesUrl. The radios get listeners instead
of onchange=; a change before the script has run is picked up by the
ready handler, as one before jQuery was. The minhash slider keeps its
small handler in the template, so its label follows at once. The
comments in base.html's first script are template comments, so they
are no longer sent with every page.
Once #310 and #312 load the graph viewer from a list of URLs instead of
plain <script> tags, plain_scripts() no longer saw main.js, main_duo.js
or d3, and the check that a plain script does not need jQuery stopped
covering them. Read the viewer lists as well.
held_back() unrouted jquery.js in release(). Called just as the queue started, it
drained nothing, and the request the browser had caught by then was never handed on,
so jQuery never loaded and release() timed out: one run in three or four of
test_a_search_keeps_the_pickers_state. The route now stays, and passes everything
through once released.
…pages

On these pages Dropzone was a script tag in the body, so its 77 KB shared the network
with what the page is painted from: Lighthouse's largest paint on mobile, the navbar
logo, came 0.5 to 0.7 s later for it.

dropzone.js is queued with later() now, as ADR-0021 asks of a page's library, and a new
static/dropzone_attach.js is queued right behind it. That attaches the form with the
options the template parks in window.mcritDropzoneOptions, and turns auto-discovery off.
Run after DOMContentLoaded, auto-discovery waits for the document to be complete, which
the queued scripts hold back, so it never sees the form first. The form keeps its
dropzone class, and so its look, from the first paint; nothing moves when it is
attached.

Running Dropzone still takes a long task, now after the first paint, where Lighthouse
counts it as blocking time.
Compiling dropzone.js, the 343 KB unminified webpack build, was most of the long task the
query, submit and import pages run once Dropzone arrives after the first paint, and with
it most of their blocking time. scripts/minify_dropzone.py strips its comments and
whitespace with rjsmin, which renames nothing, and writes dropzone-patched.min.js (221 KB,
51 KB gzipped against 77 KB), keeping the licence notices the comments carried in a
header. The upload pages and the drop overlay's loader load that file; dropzone.js stays
as the source.

tests/testAssetDiet.py checks the file still matches dropzone.js minified, that the
patch's helpers are in it, and that no template loads dropzone.js. CI installs rjsmin
1.3.0 so the first of those runs there.
@r0ny123 r0ny123 changed the title Fetch Dropzone after the first paint on the query, submit and import pages (#63, stacked on #314) Fetch Dropzone after the first paint on the upload pages, and serve it minified (#63, stacked on #314) Oct 25, 2026
r0ny123 added a commit that referenced this pull request Oct 25, 2026
It aborted static/dropzone.js, which no page loads since #324 serves the minified build,
so both of its runs measured the zone with Dropzone in. It holds back that file now, and
checks, once the queue has run, that nothing filled the zone.
# Conflicts:
#	mcritweb/__init__.py
#	mcritweb/templates/base.html
#	mcritweb/templates/import.html
#	mcritweb/templates/js/ac_family_names.html
#	mcritweb/templates/single_sample.html
#	mcritweb/templates/table/family_row.html
#	mcritweb/templates/table/function_row.html
#	mcritweb/templates/table/links.html
#	mcritweb/templates/table/sample_row.html
#	mcritweb/templates/table/submit_or_query_dropzone.html
#293 loads live_search.js with a plain script tag on the four listing
pages, so it was fetched before the first paint, which this branch moves
every page script past (ADR-0021). It is queued with later() now. The
search box has autofocus, so a term can be typed before the queue has
run: the script takes the term the page was rendered for as the one on
screen and searches what the box holds by the time it runs.
The test aborted static/dropzone.js, which no page loads since this
branch serves dropzone-patched.min.js, so both of its runs measured the
zone with Dropzone in. It holds back that file now, and checks, once the
queue has run, that nothing filled the zone.
Master's legacy-token notice and statistics page use fa-key and
fa-triangle-exclamation, which the cut stylesheet did not name.
Regenerated with scripts/subset_fontawesome.py; the fonts are unchanged.
# Conflicts:
#	mcritweb/__init__.py
#	mcritweb/templates/base.html
#	mcritweb/templates/single_sample.html
#	mcritweb/templates/table/family_row.html
#	mcritweb/templates/table/function_row.html
#	mcritweb/templates/table/links.html
#	mcritweb/templates/table/sample_row.html
#	mcritweb/templates/table/submit_or_query_dropzone.html
Master's #293 loads live_search.js with a plain script tag on the four
listing pages, so it was fetched before the first paint, which this
branch moves every page script past (ADR-0021). It is queued with later()
now. The search box has autofocus, so a term can be typed before the
queue has run: the script takes the term the page was rendered for as the
one on screen and searches what the box holds by the time it runs.
Master's legacy-token notice and statistics page use fa-key and
fa-triangle-exclamation, which the cut stylesheet did not name.
Regenerated with scripts/subset_fontawesome.py; the fonts are unchanged.
…e-scripts-to-static-files

# Conflicts:
#	mcritweb/templates/js/ac_family_names.html
#	mcritweb/templates/table/submit_or_query_dropzone.html
…dropzone-after-first-paint

# Conflicts:
#	mcritweb/templates/table/submit_or_query_dropzone.html
Each screenshot carries the pixel size of its file as width and height, but the
page is box-sizing: border-box and a screenshot has a 1px border, so the
picture inside was 2px narrower than its file (1265px for a 1267px file) and
was resampled. The border now goes around the size, and the largest width the
column allows loses the 2px, so a screenshot that does not fit still shrinks to
the column. The room kept for it before it loads is unchanged.
… size fix) into perf/page-scripts-to-static-files
…ize fix) into perf/load-dropzone-after-first-paint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant