Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. WebWorker API > Hack 64. Use the BlobBuilder Interface to Create an Inline W...

Hack 64. Use the BlobBuilder Interface to Create an Inline Worker

Sometimes developers need to keep scripts and markup together in one HTML file. When necessary, you can create an inline worker with the BlobBuilder interface. This hack will teach you how to parse batched Facebook data.

As I mentioned in this chapter’s introduction, there are three types of web workers: inline, dedicated, and shared. In this hack we will utilize an inline web worker by leveraging the BlobBuilder interface. We already covered blobs in Chapter 6, in [Hack #53].

Unlike dedicated and shared workers, inline workers do not require a worker to be maintained within an external script. Inline workers are useful in that they allow the developer to create a self-contained page. By utilizing the BlobBuilder interface, you can “inline” your worker in the same HTML file as your main logic by creating a BlobBuilder and appending the worker code as a string.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint