r/astrojs • • 13d ago

Improving performance

Hey guys, I'm very new to Astro. I used it to build my author website, and along the way I added some heavier animations. I fear I came to rely on perfect conditions too much when I test whether the site performs well, and on Lighthouse scores that don't really test the animations.

Are there any resources for optimization? Or I guess any more pointed advice to my case would also be appreciated.

...Or if you tell me it actually does run smoothly for you, then that's a win!

6 Upvotes

12 comments sorted by

2

u/Quariongg 13d ago

Samsung s20 fe 5g, runs pretty good. And honestly it's pretty cool.

One weird thing is when swiping the cards sometimes I scroll 2 rather than 1 at a time, some weird inertia thing idk.

1

u/Medium-Reveal-4917 13d ago

Oh, interesting! I haven't had that double skip in my tests, but I'll keep an eye out for it. Really appreciate you loading up the website

2

u/Likemercy 12d ago

I like that little ribbon on the first card. Really cool animation.

Performance is great, for this site I'd say you can stop chasing performance. CRO past where you are likely has little benefit in this market.

The header is hard to read though, on mobile at least. I say that as someone who's all about some low contrast and constantly getting critiqued for it.

2

u/Medium-Reveal-4917 12d ago

Thank you!! I finalized that ribbon a couple of days ago after not being satisfied with more generic tags.

I think I got worried about performance after someone who had a million tabs open told me it ran like crap for him. It's good to hear that it's fine on your end. And yes, I totally get you about the header - I've been going back and forth with different solutions because I'm unwilling to let go of the cityscape photo, but I still want to display text over it.

Thank you for trying it out!

2

u/AriadneOpsSocial 12d ago

If you want to test you can use BrowserStack. But as long as you don't add an excessive amount of CSS or overly tedious JS your Astro website will run well.

1

u/Medium-Reveal-4917 12d ago

Oh riiight, I forgot about BrowserStack. But you're right, unless I go absolutely crazy then there's probably no need to obsess over performance at this point, diminishing returns, and Astro does its thing well. Thank you!

2

u/Dwennx 12d ago

Performance is ok don’t worry ! 😊

1

u/Medium-Reveal-4917 12d ago

Thank you for checking!! So can probably relax on that front

2

u/CommonResolution5126 12d ago

Existem 2 tipos de performance e otimização

  1. Carregamento inicial do site/Lighthouse
  2. Reprodução dos efeitos em aparelhos fracos

A imensa maioria das pessoas só foca do primeiro e esquece o segundo.

Considere questões como reduzir carga de GPU, otimizar reprodução de efeitos e carga de processamento deles, se possível sempre tenha um dispositivo fuleira pra testar.

Mas com o tempo você vai vendo que é basicamente as mesmas coisas, se for usar efeito tente ao invés de empilhar um monte de coisas diferenres fazer componentes que sejam reutilizáveis.

Algumas coisas bobas que pesam em dispositivos fracos:

  • background Blur
  • drop shadow (não lembro de box shadow também)
  • e claro, 3d

Considere o público em primeiro lugar, se estiver fazendo um site por exemplo para um público gamer, provavelmente terão bons dispositivos, pode abusar um pouco mais. Se está fazendo um site de uso simples, rápido, só faça o necessário

Recentemente fiz um trabalho que era para o público geral e um site que seria utilizado rápido, onde o usuário estaria buscando uma resposta rápida para algo.

Foquei na performance (não só pra Lighthouse mas para dispositivo mesmo) ao máximo, até ativamente e conscientemente optei por remover 100% as sombras e não definir nenhuma tipografia (o site usa a tipografia do sistema do usuário), claro que não precisa ir para esse extremo em todo projeto, só para exemplificar a questão de pensar no usuário.

Fui bem generalista aqui, pense no usuário, considere reduzir carga de processamento e GPU, agentes de IA são especialmente competentes em realizar essa auditoria de otimização de carga se você pedir.

1

u/Medium-Reveal-4917 12d ago

Thank you so much for such serious advice! I'll save it and keep it in mind for when I have another optimization audit. I'll definitely keep the audience question in mind too.

1

u/tRolock5 12d ago

if you have effects below the fold, make sure those components only hydrate when they actually enter the viewport. also worth checking if you respect the prefers-reduced-motion media query for folks on older devices

2

u/Medium-Reveal-4917 12d ago

Oh yeah, I did implement out-of-viewport optimization where I could. In some cases I preferred to have everything load at once, because I wanted to avoid the awkwardness of pressing something and then having to wait for it to load. The reduced motion stuff I neglected in some elements, so I'll take another look at that. I was just being selfish there and wanted to prioritize other aspects. Thank you!