mirror of
https://github.com/miniflux/v2.git
synced 2025-08-16 18:01:37 +00:00
perf(js): don't load webauthn,js
when disabled
This saves around 1kB of data, yay.
This commit is contained in:
parent
6f2ec8b3e9
commit
3955df43f5
3 changed files with 8 additions and 3 deletions
|
@ -164,7 +164,7 @@ func Parse() {
|
||||||
printErrorAndExit(fmt.Errorf("unable to generate stylesheets bundle: %v", err))
|
printErrorAndExit(fmt.Errorf("unable to generate stylesheets bundle: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := static.GenerateJavascriptBundles(); err != nil {
|
if err := static.GenerateJavascriptBundles(config.Opts.WebAuthn()); err != nil {
|
||||||
printErrorAndExit(fmt.Errorf("unable to generate javascript bundle: %v", err))
|
printErrorAndExit(fmt.Errorf("unable to generate javascript bundle: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1114,6 +1114,7 @@ function initializeServiceWorker() {
|
||||||
* Initialize WebAuthn handlers if supported.
|
* Initialize WebAuthn handlers if supported.
|
||||||
*/
|
*/
|
||||||
function initializeWebAuthn() {
|
function initializeWebAuthn() {
|
||||||
|
if (typeof WebAuthnHandler !== 'function') return;
|
||||||
if (!WebAuthnHandler.isWebAuthnSupported()) return;
|
if (!WebAuthnHandler.isWebAuthnSupported()) return;
|
||||||
|
|
||||||
const webauthnHandler = new WebAuthnHandler();
|
const webauthnHandler = new WebAuthnHandler();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"embed"
|
"embed"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"miniflux.app/v2/internal/crypto"
|
"miniflux.app/v2/internal/crypto"
|
||||||
|
@ -117,14 +118,13 @@ func GenerateStylesheetsBundles() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateJavascriptBundles creates JS bundles.
|
// GenerateJavascriptBundles creates JS bundles.
|
||||||
func GenerateJavascriptBundles() error {
|
func GenerateJavascriptBundles(webauthnEnabled bool) error {
|
||||||
var bundles = map[string][]string{
|
var bundles = map[string][]string{
|
||||||
"app": {
|
"app": {
|
||||||
"js/tt.js", // has to be first
|
"js/tt.js", // has to be first
|
||||||
"js/touch_handler.js",
|
"js/touch_handler.js",
|
||||||
"js/keyboard_handler.js",
|
"js/keyboard_handler.js",
|
||||||
"js/modal_handler.js",
|
"js/modal_handler.js",
|
||||||
"js/webauthn_handler.js",
|
|
||||||
"js/app.js",
|
"js/app.js",
|
||||||
},
|
},
|
||||||
"service-worker": {
|
"service-worker": {
|
||||||
|
@ -132,6 +132,10 @@ func GenerateJavascriptBundles() error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if webauthnEnabled {
|
||||||
|
bundles["app"] = slices.Insert(bundles["app"], 1, "js/webauthn_handler.js")
|
||||||
|
}
|
||||||
|
|
||||||
JavascriptBundles = make(map[string]asset, len(bundles))
|
JavascriptBundles = make(map[string]asset, len(bundles))
|
||||||
|
|
||||||
jsMinifier := js.Minifier{Version: 2020}
|
jsMinifier := js.Minifier{Version: 2020}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue