lukeorth / poison

Professional Hugo theme for dev bloggers. Based on Mdo's classic Hyde theme.
https://poison.lukeorth.com
GNU General Public License v3.0
198 stars 98 forks source link

katex JS sent for every page #104

Open gabevenberg opened 1 year ago

gabevenberg commented 1 year ago

Currently, the JS for katex is included in every page, regardless of the page using katex or not. This increases the size of the sent javascript considerably. (~200kb, or most of the example site). If its not possible to only conditionally insert katex, would it be possible to render it serverside? (as katex does support that)

lukeorth commented 1 year ago

Thank you, @gabevenberg -- this is a great suggestion. The unconditional inclusion of KaTeX JS is something that has always bothered me.

The other JS features (like Mermaid) are conditional, but those use shortcodes. I tried to be clever with KaTeX and delimit using dollar signs $ ... $, but that probably wasn't the best choice. I may need to switch it to use a shortcode too.

Rendering it serverside might be a good route too. I just need to look into it some more.

I'll leave this issue open until we can figure something out. :slightly_smiling_face:

gabevenberg commented 1 year ago

honestly, shortcodes would be a perfectly acceptable solution for my usecase, but of course they would break existing sites using KaTeX.