One file, no build step, and a documented account of which parts of the usual advice survive testing. The first version of this article was wrong about the central mechanism. That is section 3.
An OBS Browser Source renders a web page and composites it over your scene. The page can be a URL or a file on your disk. A useful overlay is a few hundred lines of HTML, CSS and JavaScript, and it needs no framework, no package manager and no monthly fee. Everything in this article was run before being written down.
It is an embedded Chromium view with a fixed size, composited into the scene. Two consequences follow. Transparency is free, because the page's own background is what shows. And the Chromium inside OBS is not your Chromium: it is whatever the release pinned, so a feature you tested in a current browser may not exist in the source. Test in OBS before shipping, not after[1].
The settings that matter for a 1920x1080 overlay:
| Setting | Default | Why it matters |
|---|---|---|
| Width / Height | 800 / 600 | This is the viewport the page is laid out in, not a scale. Set it to 1920x1080 or your CSS is designing for the wrong canvas. |
| Use custom frame rate | Off | On, a separate FPS value drives redraw. Off inherits the canvas rate, which is what you want unless you are deliberately decoupling. |
| FPS | 30 | Only used when the above is on. An overlay does not need 60. |
| Shutdown source when not visible | Off | On, the page unloads when hidden or not in the active scene. Your chat state goes with it. |
| Refresh browser when scene becomes active | Off | On, the page refreshes on every scene switch. It empties the chat and can flash. |
| Local file | Off | Loads the page from disk instead of a URL. What this does and does not restrict is section 3. |
overflow: hidden on both html and body is the single most
important line in an overlay. Without it one long chat message produces a scrollbar, and a
scrollbar is visible on stream.
The first version of this article claimed that a Local file source cannot load
libraries from the internet, and explained it as a security restriction of the file://
origin. That claim is false, and I only found out because someone asked how a chat widget could
possibly work under it. I tested the four mechanisms instead of trusting the paragraph[8]:
From a page loaded as file:// | Result |
|---|---|
| A JavaScript file sitting next to the HTML | loads |
A classic <script src="https://cdn..."> | loads |
A dynamic import() of an ES module from a CDN | loads |
fetch() to a remote HTTPS endpoint | succeeds |
| Web fonts from Google Fonts | load |
fetch() to http://127.0.0.1 with no CORS header | blocked |
fetch() to http://127.0.0.1 with Access-Control-Allow-Origin | succeeds |
So a local file page can reach the network. What it cannot do is bypass CORS, which is a rule about reading responses from another origin, not about file access. The observable failure is real, and it is in the last two rows: the direction nobody tests first.
If you hit a library that would not load in OBS in 2025, the cause was most likely one of: the CDN did not send permissive CORS headers for the request the page made, the OBS release pinned a Chromium that lacked the syntax used, or the source had been cached from an earlier attempt. Each of those is worth checking before concluding that local files cannot use libraries.
file:/// as opaque origins, so two files in the same folder are not same origin, and
"may trigger CORS errors"[5]. This is why the loopback rows
in section 3 fail without a header, and why a sibling file still works: the sibling is not fetched as
a cross-origin read in the same way.--allow-file-access-from-files, documented as "an override for developers who need the
old behavior for testing"[7], and OBS will pass CEF flags
from its shortcut. Both are reasonable to try while debugging and reasonable to not ship.Yes, with one extra piece. The demo on this page fakes its own chat, because a static file cannot receive messages. Real chat arrives over a network connection, and there are two shapes that work:
| Shape | How | Trade |
|---|---|---|
| Hosted page | The overlay is served over HTTPS and connects to the chat service directly | Needs a server and a stable URL, but everything is one file and there is no local process |
| Local page plus local relay | A small program on the same machine holds the chat connection and serves it on 127.0.0.1 | Nothing leaves the machine and it works offline, but the relay must send Access-Control-Allow-Origin or the browser blocks the read |
The relay is the piece people miss, and it is about twenty lines. The browser will not let a
file:// page read a response from 127.0.0.1 unless that response opts in:
# the minimum that makes a local file able to read a local endpoint
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Content-Type", "application/json")
Then the overlay polls or opens a connection to it like any other endpoint. The wildcard is acceptable here because the endpoint is bound to loopback and holds nothing but chat you were already broadcasting.
Chat is a list that must be capped. The naive version appends forever, which is fine for ten minutes and awful for six hours.
function addMessage(who, what) {
const row = document.createElement("div");
row.className = "msg";
const n = document.createElement("span");
n.className = "who";
n.textContent = who + ":";
const t = document.createElement("span");
t.className = "what";
t.textContent = what;
row.append(n, t);
chat.append(row);
// an overlay left running for six hours must not grow without bound
while (chat.children.length > 7) chat.firstElementChild.remove();
}
Two details carry more weight than they look. Use textContent, never
innerHTML, for chat: it is attacker controlled input, and one message can otherwise inject
markup over your scene. And animate only transform and opacity, which the
compositor handles without layout work.
.msg { animation: slideIn .32s cubic-bezier(.2, .9, .2, 1) both; transform-origin: left center; }
@keyframes slideIn {
from { opacity: 0; transform: translateX(-24px) scale(.97); }
to { opacity: 1; transform: none; }
}
The follower alert is a three state machine, best driven by a class toggle so the timing lives in the stylesheet. The session clock should compute from a stored start timestamp rather than counting ticks, because background throttling makes a tick counter drift.
const started = Date.now();
setInterval(() => {
const s = Math.floor((Date.now() - started) / 1000);
elapsed.textContent = `${Math.floor(s / 3600)}:${two(Math.floor(s / 60) % 60)}:${two(s % 60)}`;
}, 1000);
This is the actual file, running, not a video of it. It fakes its chat so the motion is visible.
Four bars and backgrounds from this channel's own archive, all plain HTML, CSS and JavaScript with no build step. They were written for portfolio pages rather than OBS, which is why one of them pulls a web font from Google and would fall back to Segoe UI if that request failed.
For models and assets, these are the sources worth knowing before writing geometry by hand:
| Source | What it gives | Licence |
|---|---|---|
| three.js | 3D rendering in the browser, one file | MIT[2] |
| matter.js | 2D rigid body physics | MIT[3] |
| Kenney | Game art, audio, UI packs | Check the licence page for the specific pack before shipping |
| Quaternius | Animated and static low poly models | Check the licence page for the specific pack before shipping |
Costs below are structural, not quoted prices. Hosting tiers and overlay subscriptions change, so check the current price of any row you intend to rely on.
| Approach | Money | What you own | Fails when |
|---|---|---|---|
| Local file, vendored | 0 | The file, the assets, the behaviour | You move the folder and forget a vendored file |
| Hosted on a static host | Free tier, then per bandwidth | The file | The host, your account, or the network |
| Self hosted on a VPS | Monthly, plus your time | The file and the machine | You are now on call for a server |
| Paid overlay service | Monthly subscription | Nothing you can edit | The service changes or ends, and your overlay goes with it |
The paid services are not a scam. They are selling convenience and someone else maintaining the connection. The reason to write your own is that an overlay is small enough to understand, and the subscription never stops.
The constraint has to be in the prompt. These are the shapes that worked, including the ones that are frankly funny, because the funny ones are the ones people actually need:
hey chadgbd make me a pink rounded corner pulsating and gyrating and ribbed webcam
overlay for my twitch obs ya feel me it is local file no uploads mane
good sir gpt, i need to acquire an all in one html+css+js file that when opened as a local
file in the program known as obs creates a dopalistic hooking attention catching background
that has fireworks, randomization and gambling theory baked into it
Write vanilla HTML, CSS and JavaScript for an OBS Browser Source, 1920x1080, transparent
background. Rules:
1. One file, no build step, no package manager. It must run by opening it.
2. If it needs a library, name the file to download and load it by relative path beside the
HTML. Do not link a CDN.
3. Use textContent, never innerHTML, for anything user supplied.
4. Animate only transform and opacity.
5. Cap the number of chat rows kept in the DOM.
6. Assume an older Chromium: avoid the newest CSS and JS.
Ask for the verification too. "Give me the two commands that prove it makes no network requests at runtime" is a better request than "make it self contained", because the second one is a claim about the code and the first one is a test you can run.
html and body, overflow: hidden on both.textContent for chat and names, never innerHTML.transform and opacity only.If you want to see the output rather than the code, the videos are here and the streams are on Twitch.
file:// requesting a sibling script, a CDN classic script, a CDN ES module, a remote
fetch, web fonts, and two loopback requests with and without
Access-Control-Allow-Origin. Reproduce it before trusting it; browser behaviour changes.