var worker = new Worker("worker.js");
It would be nice to be able to inline the "worker.js" inside HTML
(just like inline SVG).
Advantages:
- If you have N workers, you don't need N external Javascript files.
(Unlike CSS, you cannot automatically merge N Javascript workers into
one giant Javascript. It will break).
- If you have large JSON inside your HTML, and you want to pass it to
the workers there is extra serialization/de-serialization overhead.
The workers can get the data by itself via XHR, but it will cost
latency. If only the JSON data can be inlined inside inlined workers
inside the HTML, that would be the most efficient way to get the data
into the worker.
My goal is to be able to serve everything inside a single HTML file.
Inlining small things like CSS, JS, small images are very useful if
you only have a single HTML page.
However, for multiple (HTML) pages it may not be useful to inline..
but that's the developers' decision.
Btw, what's the conclusion for this thread:
Felix Halim
--
You received this message because you are subscribed to the Google Groups "Chromium HTML5" group.
To post to this group, send email to chromiu...@chromium.org.
To unsubscribe from this group, send email to chromium-html...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-html5/?hl=en.
Create a string that contains the JavaScript that you want the worker
to execute.
Use a BlobBuilder to create a Blob containing that string.
Use window.createBlobURL to get the url.
Create a worker using that url.
This'll work in Chrome as of version 8.
<html>
<body>
<script id="w1" type="text/html">
postMessage('ping');
// dump large inline data here
// complex scripts here
</script>
<div id="log"></div>
<script>
function log(str) {
document.getElementById("log").innerHTML += str + "<br>";
}
var bb = new BlobBuilder();
bb.append(document.getElementById('w1').innerText);
var url = window.createBlobURL(bb.getBlob());
var w = new Worker(url);
w.onmessage = function(event) {
log("Received: " + event.data);
}
</script>
</body>
</html>
I think I can live with that :)
Felix Halim
I think if you give import scripts an absolute url, it should work.
On Thu, Oct 14, 2010 at 1:17 PM, Rick Waldron <waldro...@gmail.com> wrote:
To post to this group, send email to chromiu...@chromium.org.
To unsubscribe from this group, send email to chromium-html...@chromium.org.