perf(assets): move form-specific JS off app_include_js into doctype_js

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) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-06-24 10:14:09 +00:00
parent db32c972a9
commit 23b83b089e
2 changed files with 24 additions and 14 deletions

View File

@ -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",