A tiny local shim that saved my client demos (and the night it still failed)

How I stopped third‑party scripts from breaking client demos by running a tiny local shim and hosts redirect—what I build, the tradeoffs, and the one real failure.

Written by: Arjun Malhotra

A laptop on a desk with code editor visible and a mug beside it
Photo by Prateek Katyal on Unsplash

The client is two floors up, the meeting room has patchy AC and worse Wi‑Fi, and my demo stalls on “loading payment widget…” for a full minute. The laptop beachball spins, the PM fidgets, and I watch a script from a third‑party CDN sit in the network tab as stalled. I’d rehearsed the user flow a dozen times at home — on fibre — but here, with an ISP that rewrites TLS and a captive portal, a 3rd‑party analytics SDK had become a bullet in my head.

This kept happening. Indian client sites, small product demos, and flaky networks were exposing one hard truth: demos die on slow or blocked third‑party assets. Browsers block, CDNs fail, and your entire UI waits. So I solved it the simple way I use for other flaky external things — I faked them, locally.

Why third‑party scripts were the single point of failure Third‑party scripts are both heavy and unpredictable:

I had tried every lightweight fix: preloading, local bundling, even offline fallbacks. Those helped in controlled stalls, but not when the host simply refused connections or a browser extension blocked the domain. I needed a demo setup that guaranteed the presence and behaviour of these external endpoints — fast.

What I actually built (and why it’s stupidly small) The solution is a tiny Node.js shim and a hosts redirect. That’s it. No heavy proxies, no VPNs.

How it works, in practice:

Why this works for me:

The real failure and the tradeoffs I accepted This approach is not faithful emulation. It’s a pragmatic stub. That cost me once.

During a high‑stakes client demo in Bengaluru, my shim returned a successful init and the app advanced. Ten minutes in, when we hit the live payment sandbox, the real SDK (which our app loaded from the real CDN for the live payment flow) sent a different event sequence than my shim. My demo assumed the payment widget was ready and attempted a final confirmation. The real SDK rejected it, and the demo showed “payment failed” while the client watched. I had to explain the shim mid‑demo and then run the demo again with the real CDN — and we lost momentum.

Lessons from that failure:

Other tradeoffs I accepted:

What I actually walk away with If a third‑party asset can block your happy path in a demo, stop pretending you can make the network behave. Give your app the fast, predictable answers it needs to show value.

Practical takeaway: build the smallest shim that reproduces the app‑facing contract, run it locally with a hosts redirect, and expose a clear toggle to fall back to the real service mid‑demo. It costs almost nothing (a few hours to write, ₹300/month if you want a remote fallback) and saves most of my client nights.

Open question I still wrestle with: how much fidelity is “enough”? I aim for the minimum that keeps the user flow honest; enough to show features, not to validate partners. If you’ve built shims that also stress‑test complex SDKs, I want to know how far you go before it becomes a maintenance trap.