oleeskild / obsidian-digital-garden

MIT License
1.36k stars 125 forks source link

PageSpeed rating of 36 / eliminate unnecessary JS #311

Open shinanqu opened 1 year ago

shinanqu commented 1 year ago

Hello!

My digital garden has a perfect score on GTMetrix. On Google PageSpeed Insights it is ok on desktop. However, on mobile I always have a very low performance score of 36.

Perhaps a few things can be optimized? Perhaps some scripts can are unnecessary or can be just loaded on demand. For example I assume that 99% of digital garden users will not use mermaid diagrams. However, all digital gardens take 5 seconds longer to load because they all have to load the mermaid JS. Just getting rid of mermaid will make such a huge change at PageSpeed.

Also the obsidian-base.css is so huge with 45kb. But I guess that can't be made smaller? I wonder if all designs are included, because it's such a large file. And also the other JS like a Prism Theme and Polyfill Service, it all takes 1 second each to load and I don't know how necessary it is.

I just think that speed is for most users more important than features. If I wanted features, I would have stayed at WordPress. I think the Digital Garden should be as sleek and swift as possible.

2023_05_22_0819-g

sacgov commented 1 year ago

I just removed the mermaid.min.js from the template that is loading this. The site load much faster after this. Please do note that removing this can have unwanted effects of not being able to render certain items. As the plugin assumes availability of mermaid.

A low hanging improvement though is loading it async.

shinanqu commented 1 year ago

I assume that not many people use Mermaid (I mean from the Obsidian/Digital Garden users). But it's just an assumption. Having the ability to switch on the unnecessary JS in the options, and have it off as a default, would be great.

fs-99 commented 3 months ago

A good update path might be to only add dependencies via package.json, which is also nice to keep track of versions... hint hint

oleeskild commented 3 months ago

I've added async to most Javascript in the latest release of the template. It should deliver significantly better performance now.