|
| 1 | +<?xml version="1.0"?> |
| 2 | + |
| 3 | +<!-- |
| 4 | + Copyright (C) Nginx, Inc. |
| 5 | + --> |
| 6 | + |
| 7 | +<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
| 8 | + |
| 9 | +<article name="JavaScript Engine" |
| 10 | + link="/en/docs/njs/engine.html" |
| 11 | + lang="en" |
| 12 | + rev="1" |
| 13 | + toc="no"> |
| 14 | + |
| 15 | +<section> |
| 16 | + |
| 17 | +<para> |
| 18 | +Starting from version <link doc="changes.xml" id="njs0.8.6">0.8.6</link>, |
| 19 | +multiple JavaScript engines are supported. |
| 20 | +To specify a particular engine, use the <literal>js_engine</literal> directive |
| 21 | +available for both the |
| 22 | +<link doc="../http/ngx_http_js_module.xml" id="js_engine">http</link> |
| 23 | +and |
| 24 | +<link doc="../stream/ngx_stream_js_module.xml" id="js_engine">stream</link>. |
| 25 | +By default, the njs engine is used. |
| 26 | +</para> |
| 27 | + |
| 28 | +</section> |
| 29 | + |
| 30 | + |
| 31 | +<section id="njs_engine" name="njs engine"> |
| 32 | + |
| 33 | +<para> |
| 34 | +njs is an embeddable JavaScript engine |
| 35 | +developed as a part of the njs module. |
| 36 | +See the <link doc="compatibility.xml">Сompatibility</link> section for details. |
| 37 | +</para> |
| 38 | + |
| 39 | +</section> |
| 40 | + |
| 41 | + |
| 42 | +<section id="quickjs_engine" name="QuickJS engine"> |
| 43 | + |
| 44 | +<para> |
| 45 | +<link url="https://bellard.org/quickjs/">QuickJS</link> is a lightweight, |
| 46 | +embeddable JavaScript engine that supports |
| 47 | +the <link url="https://tc39.es/ecma262/2023/">ES2023</link> specification, |
| 48 | +including features as modules, asynchronous generators, proxies and BigInt. |
| 49 | +</para> |
| 50 | + |
| 51 | +<para> |
| 52 | +Since version <link doc="changes.xml" id="njs0.8.6">0.8.6</link>, |
| 53 | +a drop-in replacement for |
| 54 | +<link doc="reference.xml">njs/nginx objects</link> |
| 55 | +has been introduced |
| 56 | +to ensure compatibility with the njs engine, with the following exceptions: |
| 57 | + |
| 58 | +<list type="bullet"> |
| 59 | + |
| 60 | +<listitem> |
| 61 | +nginx modules API: |
| 62 | +<link doc="reference.xml" id="ngx_fetch"><literal>ngx.fetch()</literal></link>, |
| 63 | +<link doc="reference.xml" id="dict"><literal>ngx.shared.dict</literal></link>. |
| 64 | +</listitem> |
| 65 | + |
| 66 | +<listitem> |
| 67 | +Built-in modules: |
| 68 | +<link doc="reference.xml" id="njs_api_fs"><literal>fs</literal></link>, |
| 69 | +<link doc="reference.xml" id="crypto"><literal>crypto</literal></link>, |
| 70 | +<link doc="reference.xml" id="builtin_crypto"><literal>WebCrypto</literal></link>, |
| 71 | +<link doc="reference.xml" id="xml"><literal>xml</literal></link>. |
| 72 | +</listitem> |
| 73 | + |
| 74 | +<listitem> |
| 75 | +njs-specific API: |
| 76 | +<link doc="reference.xml" id="njs_dump"><literal>njs.dump()</literal></link>, |
| 77 | +<link doc="reference.xml" id="njs_on"><literal>njs.on</literal></link>, |
| 78 | +<literal>console.dump()</literal>. |
| 79 | +</listitem> |
| 80 | + |
| 81 | +<listitem> |
| 82 | +<literal>js_preload_object</literal> directive for |
| 83 | +<link doc="../http/ngx_http_js_module.xml" id="js_preload_object">http</link> |
| 84 | +and |
| 85 | +<link doc="../stream/ngx_stream_js_module.xml" id="js_preload_object">stream</link>. |
| 86 | +</listitem> |
| 87 | + |
| 88 | +</list> |
| 89 | + |
| 90 | +</para> |
| 91 | + |
| 92 | +</section> |
| 93 | + |
| 94 | +</article> |
0 commit comments