sschmidTU / mr-kanji-search-wtk

WTK-Search is a Kanji search engine using (multiple) Wanikani radicals or RTK names, on a RTK element dataset of 3000+ Kanji
https://sschmidtu.github.io/mr-kanji-search-wtk/
7 stars 2 forks source link

Further reduce search.js file size #19

Closed sschmidTU closed 3 years ago

sschmidTU commented 3 years ago

right now it's done like this (jekyll/liquid):

var docs =
[
{%- for post in site.pages -%}
{%- if post.layout == 'kanji' or post.layout == 'kanji-remain' -%}
  {%- include post.json -%},
{%- endif -%}  
{%- endfor -%}
];

but this unnecessarily puts quotes around property names (necessary in json, see post.json). Also this leaves a lot of empty "varOf" entries

-> optimize this away, put together everything programmatically (without post.json)

might need to modify the jekyll/liquid code for now. or completely rewrite it in js or so to parse the .md files

sschmidTU commented 3 years ago

New improvements in the commits starting from 549ffa10be11b131721ac3a0641722efc38838bc: Size of 417KB in 1.4.2.1 reduced to 356KB in 1.4.2.8, while adding the new alt (alternateFor) field. (last commit f6c246b0a0a9279f8aed6e55503582dcca663f50)

Improvements in post.json: Only add rare fields like alt, elWK and var when they actually exist in the .md (.size > 0).

Also, the if statements now make the formatting nicer by allowing newlines :)

https://github.com/sschmidTU/mr-kanji-search-wtk/blob/f6c246b0a0a9279f8aed6e55503582dcca663f50/_includes/post.json#L1-L4

search.js is now sufficiently optimized for size. If this is done for further rare fields, and the new fields keep short names as well, this will keep search.js optimized.