In this practice exercise, you create several short and simple pieces of code related to Web Workers. To complete the tasks required, you should:
- Understand HTML5 in general
- Be familiar with the basics of APIs
- Understand the basics of JavaScript
- Know how Web Workers communicate
Complete the following tasks:
- Given the JavaScript file name myWorker.js, write the code needed to create a dedicated Web Worker.
- After a Web Worker is spawned, what method do you use to handle the communication between the Web Worker and its parent page? How is it used?
- Messages that Web Workers pass are accessed using what event in the main page?
- Given the JavaScript file name myWorker.js, write the code needed to create a shared Web Worker.
- What distinguishes the shared Web Worker from the dedicated Web Worker?
Follow these solution steps to check your work.
-
"HTML5
fundamentals, Part 3: The power of HTML5 APIs" (developerWorks,
June 2011) provides an overview of two new HTML5 APIs: Geolocation and Web Workers.
-
The Web Workers
specification published by the WHATWG provides detailed worker information.
-
"Create
modern Web sites using HTML5 and CSS3" (developerWorks, March
2010) is a multi-component HTML5 and CSS3 tutorial.
-
In "New elements in
HTML 5" (developerWorks, August 2007), you will find
information for several of the new elements in HTML5.
-
The <html>5doctor, website provides an
excellent view of the current trends in HTML5 today.
-
The W3Schools.com: HTML5
Tag Reference provides an extensive list of the HTML5 tags and definitions as
well as examples.
-
The WHATWG
website provides detailed information for the HTML5 specification.
-
Stay current with developerWorks
technical events and webcasts focused on a variety of IBM products and IT
industry topics.
-
Follow developerWorks on Twitter.
Grace Walker, a partner in Walker Automated Services in Chicago, Illinois, is an IT consultant with a diverse background and broad experience. She has worked in IT as a manager, administrator, programmer, instructor, business analyst, technical analyst, systems analyst, and Web developer in various environments, including telecommunications, education, financial services, and software.