An embeddable AI chat widget for WordPress
The brief was deceptively small: drop a chat box onto any WordPress site with a single <script> tag. The hard part was everything the tag couldn't be allowed to break.
What I learned shipping it
- One tag, zero blocking. The embed loads
asyncand renders into a Shadow DOM, so the host theme's CSS can't bleed in and my styles can't bleed out. The host page paints first; the widget arrives whenever it's ready. - Keep keys off the browser. The widget never holds a model key — it talks to my own endpoint, which proxies the provider. The client only ever sees my origin.
- Stream for perceived speed. Tokens arrive incrementally over the stream, so the answer feels alive long before it's complete. Latency you can watch is latency people forgive.
- Ground it, then fence it. Answers are retrieved from the site's own content, and guardrails keep the bot on-topic instead of free-associating.
Front end to infra: a button anyone can paste is really a small distributed system in disguise.