perf(legacy-scripting-runner): Optimize LSR imports based on source #547
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Legacy Scripting Runner scripts have some overhead due to the loading of modules that we provide globally (e.g. underscore, moment, etc.). If we optimize the heaviest hitters (moment, jquery, and zfactory), we can see noticeable speed savings (especially for legacy apps that don't use any scripting at all!).
You might notice that this PR doesn't optimize all of the modules we load - just the heaviest hitters. That's because loading some of these takes next to no time at all. Benchmark results from Hyperfine for requiring each one individually (tested against
./nothing.js
, a file that consists ofmodule.exports = {};
):node test_require.js ./nothing
node test_require.js zapier-platform-legacy-scripting-runner/atob
node test_require.js zapier-platform-legacy-scripting-runner/btoa
node test_require.js underscore
node test_require.js crypto
node test_require.js async
node test_require.js xmldom
node test_require.js moment-timezone
node test_require.js zapier-platform-legacy-scripting-runner/zfactory
node test_require.js zapier-platform-legacy-scripting-runner/$