Skip to content

Commit

Permalink
Speed up app loading time by registering the pwa after the db is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
caarmen committed Apr 10, 2021
1 parent f1ad41a commit df23e80
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<!-- begin pwa config -->
<link rel="manifest" href="pwa/manifest.json">
<link rel="apple-touch-icon" href="icon.png">
<script src="pwa/pwa.js" defer></script>
<meta name="theme-color" content="#607D8B">
<meta id="viewport" name="viewport" content="width=600, user-scalable=yes, maximum-scale=10.0, minimum-scale=0.1">
<script>
Expand Down
3 changes: 0 additions & 3 deletions pwa/pwa.js

This file was deleted.

6 changes: 6 additions & 0 deletions src/js/model/MainModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class MainModel {
this._thesaurusRepository.settingsChangeObserver = () => this.thesaurusSettingsChangedObserver()
this._definitionsRepository = new DefinitionsRepository(db)
this._suggestionsRepository = new SuggestionsRepository(db, this._settings)
this._registerPwa()
}
_registerPwa() {
if ('serviceWorker' in navigator && !globalThis.desktop) {
navigator.serviceWorker.register('/pwa/service-worker.js', { scope: "/" });
}
}

isDesktop = () => globalThis.desktop && globalThis.desktop.desktop
Expand Down

0 comments on commit df23e80

Please sign in to comment.