Repository navigation
Conversation
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 familiary#168 (and familiary#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.
… into fix/63-page-specific-libraries Master replaced the family names shipped with each page by a type-ahead that fetches them as they are typed (familiary#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.
…house-performance
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).
…house-performance
…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.
This was referenced Oct 20, 2026
Open
Open
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.
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.
Stacked on #245, which is stacked on #126. Merge those first; until then this diff also shows their commits. This PR's own are the last two: 5f2f996, which merges #245's new head, and 901ac33.
The push that opens this PR also moves #126 from e712634 to 4c80af2, and #245 from 05a082e to 8cba370, which merges it. 4c80af2 renames #126's second ADR to 0017, since master has its own 0016, and points ADR-0015's status line at the new number. This PR's ADR is 0018.
Closes #247, and is part of #63. jQuery was the one script left in every page's
<head>that held back the first paint. #126 and #245 deferred Bootstrap and the project's own scripts, but jQuery stayed a plain script because inline blocks called$while the page parsed. This defers jQuery, jQuery UI and SortableJS, and runs the inline code that needs them from a helper that waits for them. ADR-0018 records the audit, the rule for templates and what it costs.Change.
base.htmldefineswhenReady(fn)above every other script. It waits for DOMContentLoaded and then handsfnto jQuery, so ready handlers keep the timing and order they had. The upload pages depend on that:mcritInitDropzoneneeds Dropzone's own DOMContentLoaded listener to have run first.$while the page parsed. They now run fromwhenReady: 16$(document).ready, 2$(fn), and 3 top-level bindings. So do the settings page'snew Sortable(...)calls.jquery.js, and the jQuery UI and SortableJS that result_cross and settings load in{% block style %}, are deferred. Bootstrap moves below that block, so it still runs after jQuery UI and owns$.fn.tooltip, whichcopy_to_clipboardrelies on.documentwhile the page parses. An early Enter keeps the selection and the settings instead of submitting the bare form.fetchStatereads its checkboxes withgetElementById, anddeleteSamplefinds its row withclosest("tr"), so the pagination, sort, Add, Compare and remove links work before jQuery has.#, as Explore and the user menu do. They linked to"", so an early click reloaded the page.Verification. On the testbed, #245's new head (8cba370) and this branch as side instances against the live backend, logged in as analyst1. Apart from the login, every request was a GET.
Lighthouse 12.8.2, mobile, the two sides run in turn page by page, with nothing else running. The branch side was 63b75c7, which 901ac33 amends only in the ADR's text. Each figure is the median of the runs:
//explore/samples/explore/samples/1/explore/functions/836ab3b4455ccfc2538ffea9b6jquery.jsleaves the render-blocking list on all five pages, and the first paint of the index and the samples list comes about a quarter of a second earlier. The Performance score stays within the spread of its runs, which is up to six points. The work jQuery did before the first paint now happens after it, where Lighthouse counts it as blocking time, most visibly on the function page. Desktop is 98-100 on these pages on both sides. The other three categories do not change. #245 had named jQuery as what kept mobile from 100; this does not get there on its own, and the ADR lists what the score still loses.In the browser, with
jquery.jsheld back for three seconds:$ is not defined, and an early click on the navbar's Analyze or Data menu reloaded the page.$.fn.tooltipon the cross-compare result (20 of 20 clipboard buttons), the sortable list reorders, the drop overlay opens, and the type-ahead works.Tests.
tests/testParseTimeScripts.py(210 tests) reads every template, and every page the accessibility checks render, for an inline script that reaches$,jQuery,bootstrap,Sortable,Autocomplete,csrfToken,postToormcritwebPageLoadingwhile the page parses. It also fails on a script in<head>that is not deferred, and on a plain script that needs jQuery. Its scanner knows strings, comments, regex literals and which function bodies run at once; it follows a name only to a function declaration, and its own tests hold it to that.tests/testDeferredJqueryBrowser.py(56 tests) loads those pages in Chromium and fails on any page error, and on Bootstrap not owning$.fn.tooltip. Withjquery.jsheld back, it checks:tests/testPageAssets.pypins the defers and the order of the deferred scripts, andtests/testAssetDiet.pychecks that the upload pages wire Dropzone fromwhenReady.fetchStateback on jQuery,deleteSampleback on jQuery, the flag reset, the SMDA check, a search listener bound through jQuery or bound twice, the radios' jQuery guard, andhref=""on the navbar menus.ruff check .is clean.Relation to open PRs. A trial merge (
git merge-tree) with each open PR head. #245's head already conflicts with #130, #176, #253, #254, #264, #266 and the rebuilt #160. This PR adds these conflicts:single_sample.htmlandtable/links.html. Establish UI/UX parity and design consistency across views #253 drops the sample page's Analyze flag and also widens the tooltip selector. The resolution takes Establish UI/UX parity and design consistency across views #253's side, withwhenReady(...)where it has$(document).ready(...)and$(function ...). After Establish UI/UX parity and design consistency across views #253, the flag reset this PR adds to the sample list's ready handler (table/sample_row.html) sets a variable nothing reads any more, and the ADR's note onsingle_sample.html's flag no longer applies.table/family_row.html,function_row.html,sample_row.html), where it makes the row and modal handlers delegated. The resolution keeps Filter the cheap searches as the term is typed #293's handlers and runs them fromwhenReady.base.html,cross_compare.htmlandAGENTS.md. Each side adds lines next to the other's, and the resolution keeps both.A local build of master with #126, #245, #253, #302, #303, the rebuilt #160 and this PR passes
testParseTimeScripts.pyandtestUiParity.py, with these resolutions and the twotestUiParity.pychanges #160's text describes. It still passes once #268, #291 and #292 are added.