# Worker wx.createWorker(string scriptPath, object options)

Start from base library version 1.9.90. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support, need to Mini Program base library version no less than 2.18.1

Create a Worker Thread

# parameter

# string scriptPath

worker Entry fileAbsolute path

# object options

Optional parameters

attribute type Default values Required Introductions Minimum version
useExperimentalWorker boolean false no Whether to use an experimental worker. In iOS, experimental worker JS running efficiency than non-experimental worker nearly ten times, such as the need for heavy computing in the worker is recommended to open this option. At the same time, there is a small probability that the experimental worker will be recovered by the system when the system resources are tight, so it is recommended to cooperate worker.onProcessKilled Event, which can be recreated after the worker is reclaimed. 2.13.0

# Return value

# Worker

Worker object

# Note

# sample code

// Create a normal worker
function createNewWorker() {
  const worker = wx.createWorker('workers/index.js', {
    useExperimentalWorker: true
  // Listen for worker reclaims event
  worker.onProcessKilled(() => {
    // Recreate a worker
// Create Lab Worker