Engineering Journal
Schema Editor
Schema Editor

The data file nobody loads

2026-07-17

TLDR

In non-bundled script-tag projects (<script src="...">), files can exist in the repository, be actively maintained, and be referenced in architecture comments while never actually executing in the browser because the <script> tag was omitted or deleted. When consuming modules use defensive fallbacks (window.SPECS || {}), the missing dependency fails silently without throwing console errors. Verifying dependency presence explicitly with dev-warnings or ES module imports eliminates this entire class of bugs.
Dependency PatternRuntime Error BehaviorDev ExperienceStructural Reliability
Defensive Silent FallbackSilent fallback ({})
Asserted Script LoadingLoud dev console warningImmediate missing script feedbackReliable & Self-Healing

Problem statement: the unloaded lookup table defect

During rule engine development for component pin linting, we referenced window.COMPONENT_SPECS, a data table containing symbol pin counts, pin roles, and default parameters:

/* Component Specs — Electrical Domain Lookup Table
   Keyed by data-symbol attribute value.
   Loaded only in electrical/index.html; other domains are unaffected. */
window.COMPONENT_SPECS = {
  resistor: { pinCount: 2, pins: ['1', '2'] },
  capacitor: { pinCount: 2, pins: ['1', '2'] }
};

However, running a grep search across the codebase for script tag inclusions yielded zero matches:

$ grep -rn "component-specs.js" --include='.html' --include='.js' .

(Zero results found!)

The script file existed, but no HTML file loaded it. Features reading window.COMPONENT_SPECS hit defensive fallback paths (undefined), silently skipping spec validation checks for months.


Technical failure mode: silent defensive fallbacks

Defensive runtime checks mask un-loaded dependency bugs:

// DEFECTIVE CONSUMER: Silent fallback hides missing script tag
function getComponentSpec(symbolType) {
  const specs = window.COMPONENT_SPECS || {}; // Silently evaluates to {}
  return specs[symbolType]; // Returns undefined silently!
}

Because specs evaluated to {} when component-specs.js was omitted, the application executed without throwing errors, while spec rules remained 100% inert.


The fix & architecture: explicit inclusions & Dev warnings

Step 1: include the script entry

Add the script tag to host HTML entry points prior to feature script execution:
<!-- Load component spec data table before consuming feature scripts -->
<script src="/assets/schema-editor/data/component-specs.js"></script>
<script src="/assets/schema-editor/js/features/ercEngine.js"></script>

Step 2: explicit consumer assertion warnings

Replace silent defensive fallbacks with explicit console warnings during development:
// REFACTORED CONSUMER: Loud development assertion
function getComponentSpec(symbolType) {
  if (!window.COMPONENT_SPECS) {
    console.warn('[ERC Engine] Warning: window.COMPONENT_SPECS is not loaded! Spec-based rules are inert.');
  }

const specs = window.COMPONENT_SPECS || {}; return specs[symbolType]; }

Step 3: migration to native ES modules

Migrate no-build script setups to native ES module imports to make dependencies toolchain-enforced:
// Modern ES Module Dependency (Enforced at runtime)
import { COMPONENT_SPECS } from '../data/component-specs.js';
Rule of thumb: Never rely on code comments to document script loading requirements. Enforce script dependencies using ES module import statements or loud runtime initialization warnings.
Read this post in the full Engineering Journal →