aboutsummaryrefslogtreecommitdiff
path: root/ext/sb/js/sandbox.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/sb/js/sandbox.js')
-rw-r--r--ext/sb/js/sandbox.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/sb/js/sandbox.js b/ext/sb/js/sandbox.js
index bf1d56c1..0a0ff31b 100644
--- a/ext/sb/js/sandbox.js
+++ b/ext/sb/js/sandbox.js
@@ -23,7 +23,14 @@
window.addEventListener('message', event => {
if (event.data.command === 'render') {
- const template = Handlebars.compile(event.data.template || '');
+ window.yomichan_cache = window.yomichan_cache || {};
+
+ let template = window.yomichan_cache[event.data.template];
+ if (!template) {
+ template = Handlebars.compile(event.data.template || '');
+ window.yomichan_cache[event.data.template] = template;
+ }
+
const result = template(event.data.data || {});
event.source.postMessage({result, sequence: event.data.sequence}, '*');
}