Ship a UI change to one user first
Feature-flag services are built for code you've already written and deployed. For tiny changes — a label, a size, a hidden banner — you can show a variant to one user right away, in their browser, without a deploy. Here's how to do it robustly.
Store the change, not the page
Store a small description of the change (selector plus what to set) per user, in localStorage or your backend. On every page load, read it and apply it. This is what makes a "variant of one" survive reloads.
const changes = JSON.parse(localStorage.getItem("ui-changes") || "[]");
// [{ id, selector: "#signup", props: { "font-size": "17px" } }, …]
Use CSS for styles: re-renders can't undo it
If you set element.style.fontSize, the next time React or Vue re-renders that element, your change may vanish. A stylesheet doesn't have that problem: it applies to whatever element matches the selector, whenever it's rendered.
const sheet = document.createElement("style");
sheet.textContent = changes.map((c) =>
`${c.selector} { ${Object.entries(c.props).map(([k, v]) => `${k}: ${v} !important;`).join(" ")} }`
).join("\n");
document.head.append(sheet);
!important beats the app's own rules for that element without editing them, and removing the stylesheet undoes everything at once.
Watch the DOM for text changes
Text can't be set from CSS (pseudo-elements aside), so set it on the element and re-apply when the framework replaces the element. A MutationObserver on the page catches that:
const observer = new MutationObserver(() => {
for (const c of textChanges) {
const el = document.querySelector(c.selector);
if (el && el.textContent !== c.value) el.textContent = c.value;
}
observer.takeRecords(); // ignore the mutations we just made
});
observer.observe(document.body, { childList: true, subtree: true, characterData: true });
Two details matter: check before writing (so you don't loop on your own mutations), and when an element contains an icon, replace its longest text node instead of textContent, or the icon disappears.
Make undo exact
Before changing an element, save what was there: the text, the attribute, the class list, or the element's parent and next sibling for moves. Undo restores exactly that, so "undo" never leaves the page in a third state.
Keep it safe
A runtime change system is only safe if the changes are constrained. Allow a short list of operations (text, a few attributes, layout CSS, hide, reorder siblings), refuse HTML, URLs and event handlers, and require each selector to match exactly one element. The PMF Harness safety model is one such list.
Then ask
The point of a variant of one is learning whether it helped. Ask "Is this better?" as soon as the change appears, and keep or undo based on the answer. PMF Harness packages all of this, including the stylesheet and observer approach above, in one script.