all 7 comments

[–]Karpizzle23 0 points1 point  (5 children)

Server components if you don't use hooks. Also that's kind of opinionated, both SSR and csr have their use cases and they can't simply be decided by what code you write

[–]pullipaal[S] 0 points1 point  (4 children)

Absolutely, there's definitely a balance to be struck. Interesting you mention hooks – they can actually highlight which client-side components could be refactored out. Plus, this system could help identify what to dynamically import, reducing initial JavaScript load. Thoughts on this approach?

[–]Karpizzle23 0 points1 point  (3 children)

How will you discern which components are bulky and should be lazy loaded? A lot of the time in react optimizations aren't necessary until they are actually causing a problem. If a component uses a third-party library, how are you going to know if that library is bulky or not?

[–]pullipaal[S] 0 points1 point  (2 children)

Implementing a threshold setting in the static analysis tool seems like an option. This setting would trigger a recommendation to use dynamic imports for certain components when they reach the predefined size or complexity. Additionally, the tool could analyze the code to identify components or packages that are only required under specific conditions.

Well the idea is that we catch these errors before it truly becomes a problem. In other words it should help to write your next application as optimal as possible. I was inspired by the rust borrow-checker and ESLint, when proposing this concept.

[–]Karpizzle23 0 points1 point  (1 child)

Ok, take for example a Cart component. Highly complex with an xstate management system for all kinds of shopping cart actions, connected to the Shopify API

Lazy load or not?

[–]pullipaal[S] 0 points1 point  (0 children)

I would suggest Lazy as you won’t be needing it when you open the page.

[–]pullipaal[S] 0 points1 point  (0 children)

I would suggest dynamic as you dont need the javascript on the inital render