A few months back at WordCamp Philly, we launched a plugin that brings search functionality back to static WordPress sites. We call it WP Serverless Search and it’s available on GitHub.
Despite releasing it as a beta, it has been used on a few production sites. As it’s become our go-to recommendation for search functions I wanted to revisit this plugin and test its limits.
Some quick background; the bulk of this plugin were written in about one day and the idea was simple. Use core features of WordPress such as the XML export feature to save all the content and data as a file in a local directory. That file would be used as the source for your search.
The static search file is created during plugin installation, during post save, and post edit. That combined with an open source fuzzy search library like FuseJS and a Micro Modal to display results, it was surprisingly simple to get a working demo.
By this time, I know this idea is worth exploring and I’ve noticed it some major performance benefits. Searching through our demo site of about 1,000 posts, search results are nearly instant. It takes milliseconds to fuzzy search the WordPress site. Even typing new queries, new search results are populated instantly.
So, what’s the downside? I wasn’t sure until I installed it on our super-mega-big static WordPress site with over 10,000 posts. There is clearly an upper limit to the volume of posts this plugin can parse and read. After installing the plugin, the static search file was created and it was very large. About 75 megabytes large.
I’m now thinking about how to solve this case. Whatever the solution is here I’m sure would not only benefit larger sites but also make smaller sites even faster. Here are a few ideas.
Create a smaller file. The easiest option to get this plugin started was to use the core XML export featured baked right into WordPress. While this is a simple solution, the file size could be problematic. If it’s one file we could strip out content that’s irrelevant to the search but even that’s a short-term fix. A larger volume of posts would still create a large file.
Implement REST or GraphQL to parse the data. Whether we split up the file into smaller ones or keep it as it, adding some sort of interpreter on top might be a good idea as well. If we could query only the data we need that could make the whole process better. Now I just need to figure out how to run that in the browser. Oof.
Any ideas or feedback? I’d like to hear them! Let us know what you think as we prepare to release the next version of WP Serverless Forms.