indiana-university / rivet-docs

Website and documentation for Rivet, Indiana University’s design system for web application development
https://rivet.iu.edu/
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Remove Vue.js from docs site to increase performance #17

Closed levimcg closed 5 years ago

levimcg commented 5 years ago

I like to move toward removing Vue from the Rivet docs site. We are only using it in a few places and it is adding a considerable amount of size (KBs) and processing time to our main JS bundle for not a lot of pay-off.

The problem

Really it's not so much the bundle size, although it is too large for a mostly static site at 156Kb compressed, it's more the time it takes for the page to become interactive. To demonstrate this you can click on one of the links in the sidebar in the components section.

The page content loads quite fast, but if you hover another link in the list after the new page has loaded, you'll notice that it takes about three seconds or so before the :hover underline will show up. I suspect this is being caused by the time it takes the browser to parse the JS bundle on each new page load. If we were going full-boat on Vue e.g. rendering all our content with JS, using a router, etc. this wouldn't be noticeable, but since we are the docs are mostly static HTML the browser is caching the JS bundle, but still has to parse the code again when you navigate to a new document. So it's not a network request thing, it's a CPU thing. This article has some good insights on how JS is the most expensive asset for the browser to process:

https://speedcurve.com/blog/your-javascript-hurts/

Challenges

We're using Vue to render the search bar, notifications menu, and the changelog so this will require a decent amount of development time to replace this set of functionality with another solution.

I'm interested to explore other smaller UI libraries with a smaller footprint like Preact, or hyperHTML, but I also think that we could looks at a vanilla JS implementation of most of these features.

levimcg commented 5 years ago

Before we start on this, I'd like to do capture some metrics around the how the site currently performs. We can post those to this issue thread once we get started on this.

Some things I'd like to capture so we can compare the difference after:

It might be good to start with a Lighthouse audit and go from there.

illusivesunrae commented 5 years ago

I ran audits for the four pages currently using the search bar (components, content guide, road map, and changelog), as well as the homepage for comparison. You can review the audits using the Lighthouse Viewer tool. Note: You will need to download the attached .zip and drag the -audit file for the page you wish to review into the lighthouse tool.

I have also taken screenshots of the Performance and Network tabs in Chrome for each of the pages listed above.

Here are some breakdowns between the Components page and the Homepage.

Key comparisons: Components page Time to Interactive: 10.6 s Performance Scripting time: 1183.4 ms

Homepage Time to Interactive: 3.9 s Performance Scripting time: 154.8 ms

As for the other questions, rivet-docs.js is currently 159 KB (response size) or 548 KB (content size). We are currently transferring ~194 KB of js on the Components page initial load. The site-index.json is currently 457 KB.

rivet-audits.zip

levimcg commented 5 years ago

@illusivesunrae Thanks for doing this! 🙌

Time to Interactive: 10.6 s

Is that on a simulated/throttled connection? I hope so 🙏 😬

illusivesunrae commented 5 years ago

Hah! Totally forgot to mention that. Yes, this is with the simulated "Slow 3G" option.

levimcg commented 5 years ago

Haha, I was feeling very ashamed of myself there for a minute. 🤣