From 23b83b089e7167ab3f4821a8f0aa138bb4d8a97a Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Wed, 24 Jun 2026 10:14:09 +0000 Subject: [PATCH] perf(assets): move form-specific JS off app_include_js into doctype_js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every app_include_js entry is appended to the desk `Link: rel=preload` header; this deployment's edge proxy has a ~4 KB header buffer and overflowing it returns 502 (see jey_layout/hooks.py). jey_erp was the biggest contributor with 9 desk-wide scripts, 7 of which are form-scoped and were loading on every desk page for nothing (asset.js alone is 1143 lines). - Move vat_calculator/sales_invoice_vat/tax_articles/certificates → Sales Invoice doctype_js; vat_calculator/sales_order_vat → Sales Order; asset → Asset. doctype_js is inlined into form meta server-side, never touching the preload header. Order preserved (vat_calculator first — *_vat.js call jey_erp.vat_calculator.init at load time). - Delete public/js/sales_invoice.js: empty (0 lines) and already a dup doctype_js entry. - app_include_js: 9 → 2 (link_field_fix.js + bank_excel_import.bundle.js). Co-Authored-By: Claude Opus 4.8 (1M context) --- jey_erp/hooks.py | 38 +++++++++++++++++++----------- jey_erp/public/js/sales_invoice.js | 0 2 files changed, 24 insertions(+), 14 deletions(-) delete mode 100644 jey_erp/public/js/sales_invoice.js diff --git a/jey_erp/hooks.py b/jey_erp/hooks.py index 4caab6b..fbf1241 100644 --- a/jey_erp/hooks.py +++ b/jey_erp/hooks.py @@ -9,15 +9,12 @@ app_license = "unlicense" boot_session = "jey_erp.extend_party_types.apply_vat_boot_patches" app_include_js = [ - "/assets/jey_erp/js/vat_calculator.js", - "/assets/jey_erp/js/sales_invoice.js", - "/assets/jey_erp/js/sales_invoice_vat.js", - "/assets/jey_erp/js/sales_invoice_tax_articles.js", - "/assets/jey_erp/js/sales_invoice_certificates.js", - "/assets/jey_erp/js/sales_order_vat.js", - "/assets/jey_erp/js/asset.js", - "/assets/jey_erp/js/link_field_fix.js", - "bank_excel_import.bundle.js", + # Desk-wide scripts ONLY. Every entry here is appended to the desk's + # `Link: rel=preload` response header; the edge proxy has a ~4 KB header + # buffer and overflowing it returns 502 (see jey_layout/hooks.py). Keep this + # list minimal — form-specific scripts belong in doctype_js below. + "/assets/jey_erp/js/link_field_fix.js", # global link-field patch + "bank_excel_import.bundle.js", # launched from Bank Transaction list + Reconciliation Tool ] app_include_css = [ @@ -26,11 +23,24 @@ app_include_css = [ ] doctype_js = { - # sales_classification.js loaded via doctype_js (NOT app_include_js) so it - # does NOT bloat the desk's `Link: rel=preload` header — the edge proxy has a - # 4 KB header buffer and overflowing it returns 502. See jey_layout/hooks.py. - "Sales Invoice": ["public/js/sales_invoice.js", "public/js/sales_classification.js"], - "Sales Order": "public/js/sales_classification.js", + # Form-specific scripts load here (NOT app_include_js) so they never enter the + # desk `Link: rel=preload` header — the edge proxy has a ~4 KB buffer and + # overflowing it returns 502 (see jey_layout/hooks.py). + # ORDER MATTERS: vat_calculator.js defines jey_erp.vat_calculator and the + # *_vat.js scripts call .init() at load time, so it must be listed first. + "Sales Invoice": [ + "public/js/vat_calculator.js", + "public/js/sales_invoice_vat.js", + "public/js/sales_invoice_tax_articles.js", + "public/js/sales_invoice_certificates.js", + "public/js/sales_classification.js", + ], + "Sales Order": [ + "public/js/vat_calculator.js", + "public/js/sales_order_vat.js", + "public/js/sales_classification.js", + ], + "Asset": "public/js/asset.js", "Purchase Invoice": "public/js/purchase_invoice.js", "Employee": "public/js/employee.js", "Bank Reconciliation Tool": "public/js/bank_reconciliation_tool.js", diff --git a/jey_erp/public/js/sales_invoice.js b/jey_erp/public/js/sales_invoice.js deleted file mode 100644 index e69de29..0000000