user13777150
user13777150

Reputation:

Is lazy loading better than eager loading?

I heard that lazy loading is better than eager loading? If yes then why? Want to know behind the reasons.

Upvotes: 0

Views: 185

Answers (1)

Lajos Arpad
Lajos Arpad

Reputation: 76464

To make this objective, I will define what "better" is in my answer: I consider "better" in terms of lazy-loading and eager-loading to make a list of priorities and decide what to load eagerly and what to load lazily in a wise manner.

In general, you have n resources and there are quite a lot of things which contribute to one or the other:

  • slowness of the given feature
  • server load it causes
  • probability that the user will use that feature
  • importance of the feature in average to the user

So, if we are talking about a feature which is rarely used and users tend to be patient with that feature, Lazy loading is "better". However, if it's highly probable that the user will use it, then eager loading is "better". It boils down to the question of the importance for that feature/content to be ready against server load. This is a conflict of interest between the user who would like to have everything instantly and the server which has a limited power. It is advisable to regularly monitor server load and think about the UX of your software.

Upvotes: 1

Related Questions