ramrom.io has eight tool pages: TikTok, Instagram, Facebook, YouTube, and a few more. Every one of them does the same basic job — take a pasted link, send it to the server, show the download options — but each platform needs its own small differences. Early on, I copied the JavaScript from one page to the next and changed the bits that were different. That worked for about a week. Then I fixed a bug on the TikTok page and forgot to fix it on the other seven.
That was the moment I stopped copying and built one shared engine instead.
One file, every page
The engine is a single JavaScript file that every tool page loads. It holds all the shared behaviour: reading the link box, calling the resolve endpoint, rendering the quality list, handling errors, and firing the download. None of that logic lives in the pages themselves any more.
Each page only supplies its own configuration. A page says which platform it is, which endpoint to call, and which small extras it needs — the TikTok page wants the watermarked and clean options, the YouTube page wants the audio option labelled properly, and so on. The engine reads that config when the page loads and behaves accordingly.
The config is tiny. It is just a plain object in a small inline script, something like a platform name, the resolve URL, and a couple of flags. Everything else is shared.
Why this helps more than it costs
The first win is obvious: one bug fix fixes every page. When I changed how errors are shown — an honest message instead of a spinner that never stops — I changed it once, and all eight pages got it. Before the shared engine, that same change meant eight edits, and I would have missed one.
The second win is subtler. When every page runs the same code, every page behaves the same way. A visitor who uses the TikTok downloader and then tries the Instagram one finds the same layout, the same button positions, the same error wording. That consistency is free once the engine is shared, and it would be hard work to keep up by hand.
The third win is testing. I only have to test the engine once, properly, on a real phone and a desktop browser. If the shared code works, it works on all eight pages. New pages get the tested behaviour from day one instead of starting from a copy that may already be out of date.
The hard parts
Sharing code across pages is not free. The tricky bit is the differences between platforms. If the engine has too many special cases, it becomes harder to understand than eight separate files. I keep a simple rule: if a difference is small, it goes in the page config. If a difference is big, it gets its own small function that the page can plug in. The engine itself stays generic.
Another trap is breaking every page at once. A mistake in the shared file is a mistake on all eight pages, not one. That is the real cost of this approach, and it is why I test the engine on the live site after every change instead of only checking one page. I paste a real link on each platform's page, check the quality list appears, and download a file. It takes a few minutes, and it catches the kind of break that would otherwise sit live on every page.
Versioning matters too. The script tag carries a version query string, so when I ship a fix, visitors get the new file instead of a cached old one. A shared engine is no good if half your visitors are running last week's copy.
What I would do differently
If I started again, I would build the shared engine from the second page, not the eighth. The first page is a prototype — it is fine for it to be self-contained. But the moment I made a second page that did the same job, that was the moment to extract the shared code. Waiting until I had eight copies meant I had to untangle eight slightly different versions of the same logic, and that took longer than building the engine would have.
The lesson is a simple one: duplication feels faster until the first bug you have to fix in eight places. After that, the shared file pays for itself every single week.

