linjer / jekyll-katex

[DEPRECATED] Jekyll plugin for easy server-side math rendering via KaTeX
MIT License
96 stars 8 forks source link

Extremely slow build speed. #30

Open AleksandrHovhannisyan opened 4 years ago

AleksandrHovhannisyan commented 4 years ago

As much as I'd like to use this plugin, as it performs much better than Mathjax, it's unbearably slow. What used to take 4-7 seconds to generate the feed for posts is now taking 40+ seconds:

image

hugmanrique commented 4 years ago

I went from posts rendering in 0.93 seconds to 5.2+ seconds. Is it possible to integrate the new Jekyll cache with this plugin?

AleksandrHovhannisyan commented 4 years ago

@hugmanrique What I ended up doing is following this tutorial instead of using the plugin:

https://xuc.me/blog/katex-and-jekyll/

This worked for me and didn't slow down the build speed at all (since it's loading and parsing KaTeX in real time when the page loads).

My recommendation is to conditionally include the scripts for KaTeX and jQuery in your post.html layout file (or whatever you've named it) using some kind of front matter variable in your posts (e.g., needsLatex).

hugmanrique commented 4 years ago

My site doesn't require any JS to read. I prefer 5 seconds of compile-time rather than rendering math at runtime (sending every client 250 kB + wasting time on their CPU).

This is the beauty of this plugin.

AleksandrHovhannisyan commented 4 years ago

I prefer 5 seconds of compile-time rather than rendering math at runtime

You are, of course, free to do whatever you want with your own site 🙂

But...

I went from posts rendering in 0.93 seconds to 5.2+ seconds.

I thought you were upset that your build time increased, so I mentioned an alternative solution that happened to work for me.

It's also a potential solution for anyone who's deploying to GitHub Pages since the plugin isn't supported.

Jaxan commented 3 years ago

To add to this discussion, kramdown now supports KaTeX as math output and it doesn't require javascript. See #35, building my website went from 20s to 1.5s using their approach.