Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse the parsed core-js library across VUs #1038

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions js/lib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,26 @@
package lib

import (
"sync"

"github.com/GeertJohan/go.rice"
"github.com/dop251/goja"
)

//nolint:gochecknoglobals
var (
once sync.Once
coreJs *goja.Program
)

func GetCoreJS() *goja.Program {
return goja.MustCompile(
"core-js/shim.min.js",
rice.MustFindBox("core-js").MustString("shim.min.js"),
true,
)
once.Do(func() {
coreJs = goja.MustCompile(
"core-js/shim.min.js",
rice.MustFindBox("core-js").MustString("shim.min.js"),
true,
)
})

return coreJs
}
4 changes: 4 additions & 0 deletions release notes/upcoming.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ Now all http methods have an additional param called `compression` that will mak
- windows: work with paths starting with `/` or `\` as absolute from the current drive

* JS: Correctly always set `response.url` to be the URL that was ultimately fetched (i.e. after any potential redirects), even if there were non http errors. (#990)

## Internals

* JS: VU initialization time and memory usage has been significantly decreased by caching the parsed version of the core-js library. Thanks, @matlockx! (#1038)