You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using Handlebars in my app for a few years now, after adding a new feature that would update the UI every few seconds i noticed a small memory leak with this function:
// OLD CODE
parseTemplate: function (templateName, options) {
var source = $("#"+templateName).html();
var template = Handlebars.compile(source);
var html = template(options);
return html;
}
// FIXED CODE
compiledTemplates: {},
parseTemplate: function (templateName, options) {
if (!this.compiledTemplates[templateName]) {
var source = $("#"+templateName).html();
var template = Handlebars.compile(source);
this.compiledTemplates[templateName] = template;
}
var html = this.compiledTemplates[templateName](options);
return html;
}
Now after a day or so i found handlebars-lang/handlebars.js#271 and the correct way to do this, this is not explained anywhere (that i can see) in the documentation.
The text was updated successfully, but these errors were encountered:
I've been using Handlebars in my app for a few years now, after adding a new feature that would update the UI every few seconds i noticed a small memory leak with this function:
Now after a day or so i found handlebars-lang/handlebars.js#271 and the correct way to do this, this is not explained anywhere (that i can see) in the documentation.
The text was updated successfully, but these errors were encountered: