> Is there any advantage to using service workers?
With service workers we can intercept the `fetch` request, before the index.html gets rendered/loaded.
One should (in theory) be redirected some micro-seconds faster than doing the redirect in the index.html js
trbndev · 8h ago
routr is a lightweight, offline search router inspired by DuckDuckGo's bangs. It's fully browser-based (no server requests needed other than the initial one) and routes queries like `!gh tokio` to GitHub, `!yt` to YouTube, `!hn` to Hacker News, etc.
What sets it apart:
- Runs entirely locally (no network, no tracking)
- Lets you define your own bangs and destinations
- Optionally rewrites queries for better precision (with AI)
Example:
Typing `article about german war in the stone age !!g` becomes:
`site:en.wikipedia.org "german" AND "war" AND "stone age"`
I'm working on an enhanced version of bangs. Since there are so many "dead" bangs, I'm thinking of using a bang whitelist and suggestions from the full list if not found in the whitelist.
trbndev · 1h ago
What an interesting library. Thanks for mentioning it here… will definitely look into it!
- https://unduck.link/
- https://github.com/t3dotgg/unduck
- https://youtu.be/_DnNzRaBWUU
---
Note unduck works without service workers: https://github.com/t3dotgg/unduck/blob/91a66c25de8b0e7ac5ba5...
Is there any advantage to using service workers?
edit: Ah... unduck doesn't work from the browser search bar.
https://github.com/t3dotgg/unduck/blob/91a66c25de8b0e7ac5ba5...
—-
> Is there any advantage to using service workers?
With service workers we can intercept the `fetch` request, before the index.html gets rendered/loaded. One should (in theory) be redirected some micro-seconds faster than doing the redirect in the index.html js
What sets it apart:
- Runs entirely locally (no network, no tracking)
- Lets you define your own bangs and destinations
- Optionally rewrites queries for better precision (with AI)
Example:
Typing `article about german war in the stone age !!g` becomes: `site:en.wikipedia.org "german" AND "war" AND "stone age"`
More on query rewriting and performance:
https://tl128n.github.io/writings/2025-05-02_optimizing_sear...
I wonder how much of that could be done without AI, just (locally) using https://www.npmjs.com/package/compromise
---
Also I couldn't find your source for bang data; Kagi maintains an updated list: https://github.com/kagisearch/bangs
I'm working on an enhanced version of bangs. Since there are so many "dead" bangs, I'm thinking of using a bang whitelist and suggestions from the full list if not found in the whitelist.
—-
The bangs are at
https://github.com/t128n/routr/blob/main/src/sw/routes.ts
Mostly ripped from duckduckgo.com/bang.js and then pretty-formatted with Prettier… with some sane-defaults added like a bang for ChatGPT or T3 Chat