parpalak / i.upmath.me

Upmath LaTeX Renderer
https://i.upmath.me/
MIT License
54 stars 9 forks source link

Slow rendering #8

Closed jonaprieto closed 2 years ago

jonaprieto commented 6 years ago

I'm using this for rendering my blog but It's taking now almost 8sec to load the entire page: https://goo.gl/nRtSmH I might be doing something wrong in my configurations or it just what it is expected from using SVG Rendering?

parpalak commented 6 years ago

I've run the Webpagetest for your site: https://www.webpagetest.org/result/180424_VH_9a8dd0931470805f2a6293e8b6ac05c8/1/details/#waterfall_view_step1

Here is the network waterfall:

I think it would be hard to optimize loading of SVG files itself (from ~3 to ~4.4 seconds). I consider it's normal for large number of images. But you can optimize the connection and download time of tex.s2cms.ru/latex.js (now it takes 1.057 seconds). I use the following markup:

<head>
    <link rel="preconnect" href="//fonts.gstatic.com">
    <link rel="preload" href="//tex.s2cms.ru/latex.js" as="script">
    ...
</head>

You can optimize loading content from other domains like avatars3.githubusercontent.com, fonts.googleapis.com and so on. Add them step by step and check if it reduces the page load time.

jonaprieto commented 6 years ago

Maybe I might be doing something wrong but It doesn't work. I add in the head part:

 <link rel="preload" href="//tex.s2cms.ru/latex.js" as="script">

In the footer I still have:

<script src="//tex.s2cms.ru/latex.js"></script>

But it doesn't improve or I can't notice it. If I removed the last one, nothing renders.

parpalak commented 6 years ago

Maybe you don't notice the difference because of browser cache. I'd recommend to use https://www.webpagetest.org/ to measure the delay. Here is, for example, my website loading timeline:

image

As you can see, due to <link rel="preload" ...> loading of tex.s2cms.ru/latex.js starts earlier than google-analytics and fonts.gstatic.com. This is not the case for your webpage.

jonaprieto commented 6 years ago

Ok. It's now like yours I think so.