adopted-ember-addons / ember-cli-hot-loader

An early look at what hot reloading might be like in the ember ecosystem
MIT License
99 stars 13 forks source link

Component rendering speed up (using cache for same templates) (clean) #94

Closed lifeart closed 6 years ago

lifeart commented 6 years ago

from https://github.com/toranb/ember-cli-hot-loader/pull/92

I have alot of components on page > 300items.

And after hot-loader I see some rendering perf issues. This pr solve rendering speed problem, providing caching for already compiled templates At this moment cache size is 10k items, don't think we need more.

changes in addon/components/hot-replacement-component.js

results before: image

results after:

image

Idea is: Before calling Ember.HTMLBars.compile we calculate simple template string hash. And if we have already compiled template for this hash, we reuse it, instead of compiling it one more time.

toranb commented 6 years ago

I think I understand the value add here and thank you for sending this over! Would you mind writing a few unit like tests for those 2 new functions just to better document the behavior if possible?

lifeart commented 6 years ago

Tests shipped! Including some logic comments

toranb commented 6 years ago

Thanks for the extra effort here! I've published this on npm as v1.4.0

lifeart commented 6 years ago

Np, tests is always good. :)