Skip to content
Permalink
Browse files

Improve start-up performance: Use pre-compiled pug template

  • Loading branch information...
tobias-klein committed Nov 17, 2019
1 parent 53a54f1 commit df640f1f8bb0fca3ce019a5a8ca56fac6870f20b
Showing with 5 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +0 −17 app/bible_browser/bible_browser_communication_controller.js
  3. +1 −0 index.html
  4. +3 −0 package.json
@@ -3,3 +3,4 @@
package-lock.json
*.code-workspace
/.vscode
/templates/verse_list.js
@@ -18,19 +18,6 @@

class BibleBrowserCommunicationController {
constructor() {
this.verseListTemplate = null;
}

getTemplate() {
if (this.verseListTemplate == null) {
var pug = require('pug');
var path = require('path');

var verse_list_template_file = path.join(__dirname, '../../templates/verse_list.pug');
this.verseListTemplate = pug.compileFile(verse_list_template_file);
}

return this.verseListTemplate;
}

async request_book_text(tab_index,
@@ -57,8 +44,6 @@ class BibleBrowserCommunicationController {
var verseTags = await bibleBook.getVerseTags(currentBibleTranslationId);
var groupedVerseTags = models.VerseTag.groupVerseTagsByVerse(verseTags);

var verseListTemplate = this.getTemplate();

var verses_as_html = verseListTemplate({
verseListId: current_tab_id,
renderVerseMetaInfo: true,
@@ -209,8 +194,6 @@ class BibleBrowserCommunicationController {
}

get_verses_as_html(current_tab_id, bibleBooks, bibleBookStats, groupedVerseTags, verses, render_function, renderBibleBookHeaders=true, renderVerseMetaInfo=true) {
var verseListTemplate = this.getTemplate();

var verses_as_html = verseListTemplate({
verseListId: current_tab_id,
renderBibleBookHeaders: renderBibleBookHeaders,
@@ -32,6 +32,7 @@
<script src="app/tags/tags_communication_controller.js" type="text/javascript"></script>
<script src="app/tags/tags_controller.js" type="text/javascript"></script>
<script src="app/ezra_init.js" type="text/javascript"></script>
<script src="templates/verse_list.js" type="text/javascript"></script>
</head>

<!-- BODY STARTS HERE -->
@@ -5,6 +5,8 @@
"main": "main.js",
"scripts": {
"start": "electron .",
"compile-pug": "./node_modules/.bin/pug --client --no-debug --pretty -n verseListTemplate templates/verse_list.pug",
"postinstall": "npm run compile-pug",
"rebuild": "electron-rebuild -f -w node-sword-interface -v 7.1.1",
"rebuild-win": "node_modules\\.bin\\electron-rebuild.cmd --arch=ia32 -f -w sqlite3 -v 7.1.1",
"migrate-db": "sequelize db:migrate && sequelize db:seed:all",
@@ -52,6 +54,7 @@
"node-sword-interface": "^0.90.0",
"officegen": "^0.5.2",
"pug": "^2.0.3",
"pug-cli": "^1.0.0-alpha6",
"sequelize": "^5.21.2",
"sequelize-cli": "^5.5.1",
"sqlite3": "^4.0.9",

0 comments on commit df640f1

Please sign in to comment.
You can’t perform that action at this time.