user1276919
user1276919

Reputation: 558

Web Worker - importScripts "on finished" callback

I use importScripts() to load huge JSON file (several dozens of MB) into webworker.

Is it possible to send callback when the import has been completed?

ex. self.postMessage("finished")

Upvotes: 4

Views: 1669

Answers (1)

Sylvain
Sylvain

Reputation: 375

This comes a little late but it seems that you can post a message to your worker right after you new it. Once it calls back, it means that the worker JavaScript file and its children are all fully loaded as importScripts is a synchronous call.

You can have a look at that: http://pierre.palatin.fr/entries/javascript-web-workers

Upvotes: 4

Related Questions