bestofjs / javascript-risingstars

:stars: An overview of the JavaScript landscape in 2023: trends about frontend, Node.js, fullstack frameworks, build tools, testing, Vue.js, React, state management...
https://risingstars.js.org
1k stars 56 forks source link

Improve performance using pre-rendering of category #129

Closed michaelrambeau closed 6 months ago

michaelrambeau commented 6 months ago

Goal

Improve the performance of the brand new version powered by Astro by:

Also, the opacity of the categories is changed during the loading to provide a better visual feedback.

Strategy

To make the Ajax request faster when loading content, we pre-render all of them at build time. That means using path parameters /[year]/[language]/[category] instead of query string parameters for Astro partials.

Also, to avoid having to build partials for the whole categories and for the extra projects displayed when pushing the "Show more" button, we combine both HTML in the same partial and use htmx hx-select to pick the relevant part, either the whole category or the extra projects

So now we have only one partial, in /[year]/[language]/[category].astro, with the following markup:

<Category
  projects={projects}
  year={year}
  language={language}
  category={category}
/>

<div class="extra-projects">
  <ProjectList
    projects={extraProjects}
    year={year}
    language={language}
    offset={offset}
    starDeltaReference={projects[0].delta}
  />
</div>

How to test

Inside a given category, switch between years, using the Previous / Next buttons and the dropdown: it should be fast and you should notice the change of opacity.

Scroll down:

vercel[bot] commented 6 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
javascript-risingstars ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2024 2:23am