algolia / algolia/docsearch

Runaway bundle sizes

Open
#2,769 7 comments 2 reactions 1 assignee Claimed by @dylantientcheu View on GitHub
DocSearch v4
Dominant language
TypeScript
Stars
4.4k
Forks
439
Avg merge
14h 32m
Merged PRs (30d)
19

Description

## Describe the problem

Like many OSS projects, Preact uses Docsearch [on our site](https://preactjs.com/) to support search functionality. Whilst the bundle sizes have historically been a bit larger than we'd like, and there's been [some problems with bundling](https://github.com/algolia/docsearch/issues/2230), we've generally been pretty happy with it.

So when I went to take a look at the new version a few weeks ago I was rather astounded at the bundle size as it's more than quadrupled in just a handful of minors & a major. It went from [26kb in 3.6.0](https://bundlejs.com/?q=%40docsearch%2Freact%403.6.0&treeshake=%5B%7B+DocSearch+%7D%5D&config=%7B%22esbuild%22%3A%7B%22external%22%3A%5B%22react%22%2C%22react-dom%22%5D%7D%7D) to [114kb in 4.0.1](https://bundlejs.com/?q=%40docsearch%2Freact%404.0.1&treeshake=%5B%7B+DocSearch+%7D%5D&config=%7B%22esbuild%22%3A%7B%22external%22%3A%5B%22react%22%2C%22react-dom%22%5D%7D%7D), which is rather horrific. Some [recent PRs](https://github.com/algolia/docsearch/pull/2746/files) have also bumped the bundle size warnings 30%+ at a time which is quite a big jump.

So I'd like to ask ask, is this just the new direction of the lib? Is bundle size not one of the core concerns anymore? We're sorta boxed in from the consumer side as Docsearch was already 50% of the total site JS (at least, outside of our REPL which is much heavier) and we built a custom lazy loading solution to accomodate it. Quadrupling size though, I don't think there's any way we can make that work. We have many users on poor internet connections and older devices and ~100kb of JS just for searching is a big ask.

I'm hoping this is just a temporary thing whilst perhaps you're dealing with bundler woes & complications (I think every front end dev has been there, we get it). From a quick skim it looks like we're always stuck with some AI stuff though, which we have no desire to ever use, and it looks like `marked` is being inlined too? Not totally sure on that. Obviously we're OSS consumers on donated time and resources so it's 100% cool whatever you do, I'd never make demands, but there seems to be a 180 in development priorities which, at least right now, feels like it's leaving smaller/slimmer sites behind.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.