Search code examples
sharepoint-2013web-worker

Web worker not throws error after creation in sharepoint 2013


I can't understand whether there's something in sharepoint that that's causing my web worker to throw an error as soon as its created In IE11 . The same worker runs great on chrome. Even tried a simple test:

the worker file :

     self.addEventListener('message',function(e){  console.log("message");  })    

and I'm creating the worker like so:

var worker = new Worker('http://{rootSite}/sites/53/Style%20Library/testworker.js')
worker.addEventListener('message',function(e){  console.log("message");  });
worker.addEventListener('error',function(e){  console.log("error");  });

It's strange because I tested the same script on a non sharepoint site and it worked on IE.

but on a sharepoint site as soon as create the test worker from the same site's doc library.. it throws an error.. with a null message !!

Please can anyone tell me what is going on here?!


Solution

  • Old question but I'd like to leave an answer for anyone who stumbles upon it.

    Loading a Web worker via blob in IE has many limitations. Wouldn't recommend going down that route.

    For some reason, Internet Explorer blocks Web workers from loading when the file is loaded from a sharepoint site.

    Storing your Web worker files in the _layouts folder works well.