Problem in short: Initializing a composite view in marionette with a collection of size ~500 stalls the app for around a minute.
I'm building a backbone marionette app to maintain a list of items. When testing with a collection size of ~50 everything is fine. When the limit grows, app goes unresponsive.
Store.ItemsListView = Marionette.CompositeView.extend({
tagName: "div",
template: "#items-list",
itemView: Store.ItemView,
itemViewContainer: "tbody",
emptyView: Store.NoDataView,
});
Store.ItemView = Marionette.ItemView.extend({
tagName: "tr",
template: "#store-item"
});
I understand it is mainly due to DOM interactions [CPU profiled javascript in the app page]. I tried optimizing on the template side by caching the compiled template's source instead of DOM reference in itemView. But no significant improvement.
I thought of using ItemView itself to render the collection as mentioned here. As it appends the final html src to the el. But my logic in application isn't allowing to do so.
What are other elegant ways to get rid of issues like this? Pagination is obviously one of them.. But I have a feeling that it could be handled in a better way.