diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-09-06 14:19:26 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-09-06 14:19:26 -0700 |
commit | 124ecaf8247af673109085eee8fab8d5f2bc7caa (patch) | |
tree | 4d3a39ecf8f7fa10da54e96f67445e87b3cdcaa6 /ext | |
parent | 9efe7bfe1b904db43fafda3520d702c17f44b362 (diff) |
sandbox template cache
Diffstat (limited to 'ext')
-rw-r--r-- | ext/sb/js/sandbox.js | 9 |
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}, '*'); } |