Skip to content

Conversation

@Yaros1ove
Copy link

Added HOC to lazy load component when it reaches viewport
Made all examples tabs and contributors list lazy loaded on the main page to optimize perfomance

@dgaponov
Copy link
Contributor

Loader is strangely positioned. You need to center the Loader horizontally and vertically

It is also worth increasing the height of the block during Loader display so that it matches the height of the block after loading is completed.

image

@dgaponov
Copy link
Contributor

Let's add a border so that the block looks more like the final one after loading.

border: 1px solid var(--g-color-line-generic);
border-radius: 16px;

Before:
image

After:
image

@Yaros1ove
Copy link
Author

Loader is strangely positioned. You need to center the Loader horizontally and vertically

It is also worth increasing the height of the block during Loader display so that it matches the height of the block after loading is completed.

image

Have not met this in local development. I think this is because of absence of css file import in LazyComponent (only in component itself). Added this import. Hope it works.

@Yaros1ove
Copy link
Author

Let's add a border so that the block looks more like the final one after loading.

border: 1px solid var(--g-color-line-generic);
border-radius: 16px;

Before: image

After: image

fixed

};

const getComponentProps = async () => {
const contributors = await Api.instance.fetchAllContributorsWithCache();
Copy link
Collaborator

@imsitnikov imsitnikov Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't call Api.instance.fetchAllContributorsWithCache() from client code, we don't have github credentials on client side and will get rate limiting errors:

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added Next.js server-side endpoint at src/pages/api/contributors.ts and a fetchAllContributorsFromClient method to the Api that calls api/contributors
This seems to have solved the issue

return;
}

const contributors = await Api.instance.fetchAllContributorsWithCache();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stepanenkoxx take a look plz, as far as I remember, the cache inside Api.instance didn't work with API routes, but now in dev and prod modes everything looks okay.

Copy link
Collaborator

@stepanenkoxx stepanenkoxx Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I remember, the problem was that Next worked in such a way that the API routes and pages had different instances of Api class
So cache in API routes and cache in pages works but it's different cache, so it will add some more actual github api calls
I will check it now

Copy link
Collaborator

@stepanenkoxx stepanenkoxx Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i checked and there are really different instances
so contributors cache warmup in /health route doesn't make sense now

don't know, maybe we must call Api class methods only in api route "layer" and make api routes for all methods
and call this routes from server and client

src/api/index.ts Outdated
Comment on lines 250 to 254
async fetchAllContributorsFromClient(): Promise<Contributor[]> {
const res = await fetch('api/contributors');
return (await res.json()).contributors;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should separate classes here for ServerApi and ClientApi?
To avoid confusion and not call server methods from the client

@Yaros1ove Yaros1ove force-pushed the lazy-load-main-page-components branch from 1aa6fc0 to f7ed75f Compare November 19, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants