js_engine

The `js_engine` directive specifies the JavaScript engine to be used for processing JavaScript code in NGINX.

Syntaxjs_engine engine_name;
Defaultnone
Contextstream, stream server
Arguments1+

Description

The js_engine directive is used to specify which JavaScript engine will be utilized for executing JavaScript code within the NGINX context. This directive can be utilized in both stream and stream server contexts, allowing for greater flexibility in handling JavaScript executions in reactive networking scenarios. By defining which engine to employ, it ensures that the JavaScript code adheres to the capabilities of the chosen engine,
thereby maximizing performance and compatibility. As of the available implementations, some engines like QuickJS and Duktape offer differing performance and feature sets, making selection critical for specific use cases.

This directive accepts one or more arguments, which typically will be the names of the engines. Depending on the parameters passed, the behavior of script compilation and execution can vary. For the systems that support multiple engines, it’s important to ensure that the appropriate engine is selected to match the syntactic and functional properties of the script being executed. Misconfiguring this directive can lead to script failures or suboptimal performance, necessitating careful testing and validation of the implementation. Moreover, implementing the directive at the correct context level—either at stream or stream server—is essential to ensure behavior aligns with application architecture.

Config Example

js_engine quickjs;

Ensure the chosen JavaScript engine is compatible with the scripts intended to run; incompatible syntax or features may cause runtime errors.

Check for the correct context of usage; applying the directive in an unsupported context will result in configuration errors.

Be mindful of performance implications when selecting different engines, as they may have varying execution speeds and memory usage.

← Back to all directives