1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

feat(js): load app.js using JavaScript module

- The JS bundle has its own isolated scope
- There is no need to use IIFEs anymore (Immediately Invoked Function Expressions)
- Modules are executed after the HTML document is fully parsed, similar to `defer` attribute
- There is no need to use `DOMContentLoaded` anymore
- Module scripts inherently run in strict mode (no need to define `use strict` anymore)
This commit is contained in:
Frédéric Guillot 2025-08-02 10:50:00 -07:00
parent 50197c2be3
commit bfbc1c88c3
4 changed files with 172 additions and 187 deletions

View file

@ -127,14 +127,6 @@ func GenerateJavascriptBundles() error {
},
}
var prefixes = map[string]string{
"app": "(function(){'use strict';",
}
var suffixes = map[string]string{
"app": "})();",
}
JavascriptBundles = make(map[string][]byte)
JavascriptBundleChecksums = make(map[string]string)
@ -146,10 +138,6 @@ func GenerateJavascriptBundles() error {
for bundle, srcFiles := range bundles {
var buffer bytes.Buffer
if prefix, found := prefixes[bundle]; found {
buffer.WriteString(prefix)
}
for _, srcFile := range srcFiles {
fileData, err := javascriptFiles.ReadFile(srcFile)
if err != nil {
@ -159,10 +147,6 @@ func GenerateJavascriptBundles() error {
buffer.Write(fileData)
}
if suffix, found := suffixes[bundle]; found {
buffer.WriteString(suffix)
}
minifiedData, err := minifier.Bytes("text/javascript", buffer.Bytes())
if err != nil {
return err