static-portfolio-build — Static Multi-Page Portfolio
Technical Boundaries: Only HTML5 + CSS3 + Vanilla JS. No Bootstrap/Tailwind or other UI frameworks, no external CDN fonts. Max 3 primary colors, max 2 fonts, every image must have
alt(SVG userole="img"+aria-label). Initial load on 3G ≤3s (estimated at 1.6Mbps / RTT 400ms).
1. Architecture: Data-Driven, Single Source of Truth
Do not hand-write portfolio content in each HTML file. Extract it into JSON data + a rendering layer:
works-data.json Data source (script-generated, do not edit manually)
works-data.js Inline copy of the data (window.__WORKS_DATA__) — for file:// double-click to bypass CORS
works.js Rendering layer: ROLES / cardHTML() / tileHTML() / bindFilter() / bindExpand()
extract-works.mjs Extract from old single page
patch-works.mjs Re-number, fill modules, assign motif (must be idempotent!)
Why an inline JS copy is necessary: fetch('./works-data.json') is blocked by CORS under file:// protocol. Without it, double-clicking the page results in a white screen.
Idempotent Patch Script: patch-works.mjs must be safe to run repeatedly. Use EXTRA_TITLES to filter out already-patched entries, otherwise the second run throws "not in mapping table".
Align Module Numbers with Actual Directories: Portfolio IDs should not be grouped by category, but by the actual directory/GitHub repository structure. Follow "align with directory numbers if there is a directory, fill gaps with placeholder numbers" to ensure a continuous sequence with no gaps. When renumbering, all cross-references (entry cards, role page banners, about page categories) must update synchronously — best to let entry cards be auto-generated from data, eliminating manual synchronization errors:
document.querySelectorAll('[data-owns]').forEach(function (el) {
var r = WORKS.ROLES[el.getAttribute('data-owns')];
if (r) el.textContent = 'Hosts ' + r.owns.length + ' modules (' + r.owns.join(' / ') + ')';
});
2. No Screenshots? Use Inline SVG Diagrams
Most projects won't have screenshots. Assign geometric motifs per category and generate inline SVGs (zero external images, zero image requests on initial load):
| Category | Motif | Elements |
|---|---|---|
| Planning | roadmap | Nodes + dashed connections + milestones |
| Workflow | pipeline | Input → Processing → Review → Output + arrow markers |
| Agent | neural | Layered nodes + fully connected edges |
| Data | metrics | Bars + line trend |
| Open Source | terminal | Dark window + colorful code lines + cursor |
| Industry | grid | Blueprint grid |
Every SVG must include role="img" + a semantic aria-label.
Pitfalls Encountered:
- Drawing
<text>inside an SVG gets obscured by card gradients → Move labels out of the SVG, use an HTML overlay.w-cover-tag(position:absolute) - Use
meetforpreserveAspectRatio, notslice, to avoid cropping - Array index mismatch: Motif data was written as
[x,y,text,color]but the rendering code treated it as[x,y,width,color]and accessedl[2]→ All rectangles became invisible, only the cursor showed. When writing motifs, first confirm that index semantics are consistent.
3. 3D & Animations (Beautiful but No Frame Drops)
Background: SpaceX-style Perspective Grid
.bg-grid-floor {
position: absolute; left: -30%; right: -30%; top: 16%; height: 90%;
background-image:
repeating-linear-gradient(90deg, rgba(10,10,10,.16) 0 1px, transparent 1px 74px),
repeating-linear-gradient(180deg, rgba(10,10,10,.15) 0 1px, transparent 1px 40px);
transform: perspective(520px) rotateX(72deg) translateZ(0);
transform-origin: 50% 0%;
mask-image: linear-gradient(to bottom, transparent 0%, #000 11%, #000 52%, transparent 90%);
animation: floorDrift 30s linear infinite; /* animate background-position, not transform */
}
Overlay a horizon glow line + three drifting light blobs (each with 24/29/34s breathing).
Performance Golden Rule (This Is the Frame-Drop Watershed)
Never use filter: blur() or backdrop-filter. Both trigger re-rasterization/re-sampling of background content every frame — the #1 cause of scroll jank:
- Soft light blobs: use
radial-gradient(circle, rgba(...).10, transparent 68%)— gradients are inherently soft, no blur needed - Frosted glass navigation: use a near-opaque background
rgba(255,255,255,.96) - Section backgrounds: use semi-transparent white backgrounds, never
backdrop-filter
Animate only transform / opacity (handled by the compositor, no reflow/repaint). For scroll parallax, use requestAnimationFrame throttling + translate3d.
Card 3D Tilt
Use pointermove to write CSS custom properties, never touch the DOM directly:
.tilt { transform: perspective(1000px) rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)); }
.tilt.is-tilting { transition: transform .06s linear; } /* reduce transition latency when tracking */
.tilt .w-body { transform: translateZ(18px); } creates a parallax floating effect; ::before radial highlight follows --mx/--my.
Hover displacement and entry animations both use transform → Hover only modifies box-shadow/border-color; all position changes are delegated to .tilt.
4. Entry Animations: Never Use Pure CSS opacity:0
This is the biggest pitfall. If you hide elements with pure CSS opacity:0 and then add .is-revealed via JS, a failure in IntersectionObserver (headless browser, JS error, unexpected path) will render the entire page permanently invisible.
Correct approach: Let JS conditionally add the hidden state class — elements without that class remain visible by default:
.w-card.reveal-armed { opacity: 0; transform: translateY(18px); }
.is-revealed { opacity: 1 !important; transform: none !important; }
list.forEach(function (el) {
var r = el.getBoundingClientRect();
var inView = r.top < innerHeight + 150 && r.bottom > -150;
if (!inView) el.classList.add('reveal-armed'); // only hide those outside the viewport
io.observe(el);
});
// Fallback: force-reveal after 3 seconds if still hidden
setTimeout(function () { /* force reveal */ }, 3000);
Elements in the viewport remain immediately visible; only those outside are "armed" — the initial viewport is never delayed by animations, and error paths produce no white screen.
5. Script Injection: Validate <script> Open/Close Pairs
When batch-injecting code into multiple pages, you must verify that the number of <script> tags equals the number of </script> tags.
Real Incident: An extra <script> open tag was injected → the subsequent inline script block was consumed by the JS parser → all four role page rendering scripts failed entirely. The pages looked perfectly normal (titles, navigation, responsibilities were all there), only the project area was blank — barely noticeable by eye.
When using regex for injection, note that LastIndexOf('<script>') will also match <script src=...>, causing the definition to be inserted outside the tag, becoming visible text. Use a distinct anchor string instead.
6. Verification Methods (Reusable)
Screenshot Verification (Key: Same File Names Use Cache)
vision_html_screenshot caches results for files with the same name. After changing CSS, you must Copy-Item to a temporary name in .verify/, take the screenshot, then delete the sandbox.
Sync Probe (Don't Use load + setTimeout)
In headless environments, window.load + setTimeout is unreliable. Write the probe inside the render callback (synchronous), outputting to a <pre> with position:fixed;bottom:0:
WORKS.loadData(function (data) {
root.innerHTML = WORKS.listByRole(data.items, 'fde');
var d = document.createElement('pre');
d.style.cssText='position:fixed;bottom:0;left:0;right:0;z-index:99999;background:#000;color:#0f0;font:11px monospace;padding:4px;margin:0';
d.textContent = 'CARDS=' + root.querySelectorAll('.w-card').length;
document.body.appendChild(d);
});
⚠️ Do not use top for probe positioning — the card 3D tilt transform can shift fixed elements.
Batch Verification (More Efficient Than Reading Each File)
- Broken links: Use regex to extract
./xx/yy.md→Test-Pathon each - Number continuity:
Compare-Objectexpected sequence vs actual - Directory alignment: PowerShell converts
'01'to int 1 — must use[string]to force string comparison - Expensive feature remnants:
[regex]::Matches($css,'filter:\s*blur|backdrop-filter')— be careful to distinguish comments
7. Deploy to GitHub Pages
gh repo create <user>/<repo> --public --description "..."
git remote add origin https://github.com/<user>/<repo>.git
git push -u origin main
Pre-deployment Checks:
git ls-filesto verify dependent directories are actually tracked (having files locally ≠ git tracking)- If remote already has content, first
git ls-tree --name-only origin/mainto compare — don't overwrite and lose things - For sibling project directories that use relative local paths: either push them together, or change to GitHub repository URLs
- GitHub Pages requires Settings → Pages → Source to select a branch
- If there's a sub-application (e.g.,
hitech-self-assessment/), ensure it isn't overwritten by the main site
Performance Estimate: Total bytes / 8 / 1.6e6 + 4 * 0.4 (seconds)
8. Pre-delivery Self-Check (Align with web-delivery-checklist)
- All four/five pages have been verified via screenshots (not just the homepage)
- Zero broken links, zero missing
alt -
<script>open/close pairs match, CSS curly braces are balanced - Actual count of
filter: blur/backdrop-filterin use = 0 - 3G estimated load time < 3s
- Max 3 primary colors, max 2 fonts, zero external CDN resources
- Mobile (390px) hamburger menu can open/close,
aria-expandedis synchronized - All animations are disabled under
prefers-reduced-motion