TikTok for Developers

Developer Docs

Last updated October 1, 2026

Subpackage Loading

JSBridge APIs for managing the download and execution of subpackages.

Note: The difference between TTMinis.game.preDownloadSubpackage and TTMinis.game.loadSubpackage:

  • TTMinis.game.preDownloadSubpackage only downloads the code package without automatically executing the code.
  • TTMinis.game.loadSubpackage will automatically execute the code after downloading the code package.

TTMinis.game.preDownloadSubpackage(opts)

Triggers subpackage pre-download.

Parameters

Field

Type

Description

Required

name

string

The name of the subpackage

Yes

success

function

Callback function called when the subpackage download succeeds

Yes

fail

function

Callback function called when the subpackage download fails

Yes

complete

function

Callback function called when the subpackage download ends (called on both success and failure)

Yes

Returns

A PreDownloadSubpackageTask instance for monitoring the subpackage pre-download progress.

Example

var task = TTMinis.game.preDownloadSubpackage({
  name: "ModuleA", success(res) {
    console.log("load subpackage success", res)
    TTMinis.game.loadSubpackage({
      name: "ModuleA", success(res) {
        console.log(res)
      },
    })
  }, fail(res) {
    console.log("load subpackage fail", res)
  }
})

task.onProgressUpdate(res => {
  console.log(res.progress)
  console.log(res.totalBytesWritten)
  console.log(res.totalBytesExpectedToWrite)
})

TTMinis.game.loadSubpackage(opts)

Triggers subpackage loading and execution.

Parameters

Field

Type

Description

Required

name

string

The name of the subpackage

Yes

success

function

Callback function called when the subpackage loading succeeds

Yes

fail

function

Callback function called when the subpackage loading fails

Yes

complete

function

Callback function called when the subpackage loading ends (called on both success and failure)

Yes

Returns

A LoadSubpackageTask instance for monitoring the subpackage loading progress.

Note: The difference between TTMinis.game.preDownloadSubpackage and TTMinis.game.loadSubpackage is that preDownloadSubpackage only downloads the code package without executing the code, while loadSubpackage downloads and automatically executes the code after download completes.

LoadSubpackageTask.onProgressUpdate(listener)

Registers a listener for subpackage loading progress change events.

Parameters

Field

Type

Description

Required

listener

function

The listener function for subpackage loading progress change events

Yes

Listener callback parameters

Field

Type

Description

progress

int32

Subpackage download progress percentage

totalBytesWritten

int64

Number of bytes downloaded so far

totalBytesExpectedToWrite

int64

Total number of bytes expected to be downloaded

PreDownloadSubpackageTask.onProgressUpdate(listener)

Registers a listener for subpackage pre-download progress change events.

Parameters

Field

Type

Description

Required

listener

function

The listener function for subpackage pre-download progress change events

Yes

Listener callback parameters

Field

Type

Description

progress

int32

Subpackage download progress percentage

totalBytesWritten

int64

Number of bytes downloaded so far

totalBytesExpectedToWrite

int64

Total number of bytes expected to be downloaded

TikTok for Developers