Aren’t static sites already fast?
Yes! Static sites can have serious performance advantages. However, there are several “gotchas” where they can be slowed down dramatically.
- Slow DNS lookup
- Slow server response
- Slow SSL negotiation
- No asset compression (GZIP, Brotli, etc.)
- No server-side caching
- Resources spread out over lots of domains (CDNs, third-party scripts, Google fonts, etc.)
It’s possible to have these all dialed in, but even a highly-optimized server is sometimes not able to deliver smooth, instantaneous navigation.
Popular hosting services like Netlify and Github Pages do a lot of these optimizations for you. That said, users on average connections can wait at least 300ms for page loads.
How does Schwifty solve this problem?
Schwifty acheives crazy-fast speeds by preloading and caching same-origin pages. It essentially
lazy-loads lazy-preloads links as they scroll into view. When a link is clicked, the content is swapped out and navigation happens.
Finally, Schwifty is built for the lightest possible client-side load. That’s why it’s only 1.1kb.
Git & Github
I used git branches to add new features, and published the library on Github with comprehensive documentation.
I used the esbuild bundler to generate a minified version of the library.
View Schwifty.js on Github