JS_Init

This article covers features introduced in SpiderMonkey 31

Initializes the JS engine so that further operations can be performed.

Syntax

#include "js/Initialization.h" // previously "jsapi.h"

bool
JS_Init(void);

Description

Initialize SpiderMonkey, returning true only if initialization succeeded. Once this method has succeeded, it is safe to call JS_NewRuntime and other JSAPI methods.

This method must be called before any other JSAPI method is used on any thread. Once it has been used, it is safe to call any JSAPI method, and it remains safe to do so until JS_ShutDown is correctly called.

It is currently not possible to initialize SpiderMonkey multiple times (that is, calling JS_Init, JSAPI methods, then JS_ShutDown in that order, then doing so again). This restriction may eventually be lifted.

In the past JS_Init once had the signature JSRuntime * JS_Init(uint32_t maxbytes) and was used to create new JSRuntime instances. This meaning has been removed; use JS_NewRuntime instead.

See Also