wowthemesnet / mediumish-theme-jekyll

Jekyll Template - Mediumish
https://wowthemesnet.github.io/mediumish-theme-jekyll/
MIT License
1.29k stars 1.53k forks source link

Lunr search performance #127

Open jcuenod opened 4 years ago

jcuenod commented 4 years ago

I am experiencing significant performance issues with lunr.js.

I have about 250 posts of 500-1000 words which means my searchengine file is about 500kb. The real killer though is execution (consistently greater than 5s).

I thought defer would be an adequate fix but it doesn't seem to be (I'm still trying to figure out why but lunr is definitely still delaying rendering).

There are a number of possible solutions here:

  1. The most interesting one is an idea I had to use something like Cloudflare workers
  2. Perhaps more realistic for the theme is to figure out how to adequately defer the script's execution or somehow break it into smaller async pieces.

[EDIT:] It looks to me as though I'm having the same problem as this: https://github.com/mkdocs/mkdocs/issues/859

This suggests that prebuilding the index (and compressing) and using a webworker in the middle (presumably for caching) would alleviate a lot of this pain... (cf. https://github.com/mkdocs/mkdocs/pull/1418)