I have the following module:
define('jsViz',['require','jquery'],function (require) {
var scripts = document.getElementsByTagName("script"),
src = scripts[scripts.length-1].src,
dotWorker = new Worker("/JSViz/main.js?v=2");
});
scripts[scripts.length-1].src
returns domain/dist/js/index.js
which is the URL of currently executing script. Worker constructor accepts relative path to the currently executing script, so when I specify /JSViz/main.js
I assume the script will be loaded from domain/dist/js/JSViz/main.js
, however the browser tries to load script from domain/JSViz/main.js
. Why so?
PS. The module definition is from r.js optimization output that's why the module is named.
According to http://www.w3.org/TR/workers/
When the Worker(scriptURL) constructor is invoked, the user agent must run the following steps:
Resolve the scriptURL argument relative to the entry script's base URL, when the method is invoked.