When you search your Jottings microblog, something interesting happens: nothing reaches our servers.
Your search query stays on your device. The results appear instantly. No API calls. No tracking. No latency.
This is by design.
The Traditional Search Problem
Most websites handle search the obvious way: you type something, it hits their server, and they search their database.
It works, but it comes with baggage:
- Server costs: Every search is a database query
- Latency: You wait for the network round-trip
- Privacy concerns: Your searches are logged somewhere
- Scaling headaches: Popular sites need search infrastructure
- Tracking: Analytics platforms capture every keystroke
For a platform like Jottings—where we want to minimize costs and maximize privacy—this didn't feel right.
The Insight
Here's the thing about searching your own site: you already have all the data.
When you publish a jot, it's instantly available to you. Your site visitors can read everything. So why send search queries to a server when all the data is already in the browser?
That's when I discovered Lunr.js.
What Is Lunr.js?
Lunr.js is a small JavaScript library that lets you build full-text search indexes in the browser. Think of it as a lightweight search engine that runs on the client side.
Here's how it works:
- When your site loads, we download a compressed search index (usually under 50KB)
- Lunr builds its search data structure in memory
- When you search, Lunr finds matches instantly—no network call needed
- Results are ranked by relevance using TF-IDF scoring
The entire thing is self-contained. No external services. No API dependencies.
The Benefits (For You)
Instant Results: Search is faster than your network connection. Type and get results immediately.
Privacy: Your searches never leave your device. We have no visibility into what you search for. Your writing stays yours.
Works Offline: If you download your site or read it on an airplane, search still works. Every feature is self-contained.
No Costs: Client-side search means zero server infrastructure. That cost savings gets passed to you through lower subscription prices.
Better UX: No loading spinners. No "searching..." delays. Just instant, snappy results that feel native.
The Tradeoffs
Nothing is perfect, so let me be honest about the tradeoffs.
Doesn't Scale to Massive Collections: If you have 50,000 jots, the search index might be 500KB instead of 50KB. Still reasonable, but noticeable. Most people publish dozens or hundreds of jots, not tens of thousands.
Search Index Download: The first time someone visits your site, they download the search index. It's compressed, but it's still a one-time cost.
Limited Search Features: You get basic full-text search with stemming and ranking. You don't get "advanced filters by date" or "search with AND/OR operators." We kept it simple because simple is what people actually use.
Static Index: The search index is generated when you publish. If you jot something and refresh immediately, it might not be searchable for a few seconds. In practice, this is fine—it's rare you search for something you just published.
How It Works on Jottings
When you build your Jottings site, our build system does the heavy lifting:
- It reads all your jots
- It processes their titles, content, and tags
- It builds a Lunr search index
- The index gets embedded in your site
When someone visits your site and types in the search box:
- Lunr.js queries the index in memory
- Results appear before you finish typing
- No network requests. No server load. Just JavaScript doing what it does best.
The Future
We're already thinking about how to improve this. Some possibilities:
Fuzzy Matching: Handle typos gracefully ("serarch" finds "search")
Weighted Search: Prioritize matches in titles over content
Filter by Tags: Combine full-text search with tag filtering
Search Analytics (Optional): If you want to understand what people search for on your site, we could offer opt-in analytics that process searches locally and only send you aggregated trends.
All of these are possible with Lunr.js because it's so flexible.
Why This Matters
Client-side search is a small feature, but it represents something bigger: a platform that respects your privacy and keeps costs low by doing smart engineering.
We could have built a cloud search service. We could have integrated Algolia or Elasticsearch. They're great products. But they come with fees and complexity.
Instead, we chose the path of simplicity: put the power on your device, and let it do the work.
Your jots are yours. Your site is yours. And your searches? Those stay private too.
Try it out: Create a Jottings site, publish a few jots, and search your work. The search box appears on the home page and tag pages. No setup required—it just works.
Ready to try Jottings? Start your free site today and publish your first jot in seconds.