FASE 7: Quick Wins de Performance — Optimización Fase 1

Cambios implementados:

1. Nginx:
   - gzip on (compresión JS/CSS/JSON)
   - Cache headers para assets estáticos (6M)
   - Proxy buffer tuning (10s connect, 30s read)

2. Frontend catalog.js:
   - Reemplazados 8x innerHTML += en loops por map+join
   - Event delegation en breadcrumb y cart (elimina memory leak)
   - AbortController en apiFetch (evita race conditions)
   - sessionStorage cache para years-all y brands por modo

3. Frontend templates HTML:
   - defer en todos los scripts POS (mejora First Paint)

4. Dashboard JS:
   - innerHTML += fix en dashboard.js y cuentas.js

5. Base de datos:
   - Índice parcial idx_wi_part_stock_positive en warehouse_inventory

6. Documentación:
   - docs/performance_audit_2026.md con análisis completo y roadmap

Tests: 73/73 pasando (compat + fase3 + fase5 + fase6)
This commit is contained in:
2026-04-27 07:19:37 +00:00
parent efbd763e43
commit 175dda6212
19 changed files with 813 additions and 146 deletions

View File

@@ -161,12 +161,12 @@
// Populate invoice dropdown for payment form
var invSelect = document.getElementById('pay-invoice');
invSelect.innerHTML = '<option value="">Abono general</option>';
res.invoices.filter(function (i) { return i.status !== 'paid' && i.status !== 'cancelled'; })
.forEach(function (i) {
invSelect.innerHTML += '<option value="' + i.id_invoice + '">' +
var options = res.invoices.filter(function (i) { return i.status !== 'paid' && i.status !== 'cancelled'; })
.map(function (i) {
return '<option value="' + i.id_invoice + '">' +
i.folio + ' — ' + fmt(i.total - i.amount_paid) + ' pendiente</option>';
});
}).join('');
invSelect.innerHTML = '<option value="">Abono general</option>' + options;
});
}

View File

@@ -509,19 +509,15 @@ class VehicleDashboard {
if (yearsRes.ok) {
const years = await yearsRes.json();
const yearFilter = document.getElementById('yearFilter');
yearFilter.innerHTML = '<option value="">Todos los años</option>';
years.forEach(year => {
yearFilter.innerHTML += `<option value="${year}">${year}</option>`;
});
yearFilter.innerHTML = '<option value="">Todos los años</option>' +
years.map(year => `<option value="${year}">${year}</option>`).join('');
}
if (enginesRes.ok) {
const engines = await enginesRes.json();
const engineFilter = document.getElementById('engineFilter');
engineFilter.innerHTML = '<option value="">Todos los motores</option>';
engines.forEach(engine => {
engineFilter.innerHTML += `<option value="${engine}">${engine}</option>`;
});
engineFilter.innerHTML = '<option value="">Todos los motores</option>' +
engines.map(engine => `<option value="${engine}">${engine}</option>`).join('');
}
} catch (error) {