HTML and CSS Reference
In-Depth Information
Thought experiment
Creating a page that performs a fireworks show
In this thought experiment, apply what you've learned about this objective. You can
find answers to these questions in the “Answers” section at the end of this chapter.
As an exercise to create a webpage using timeouts and intervals, think about how
you would create a page that would perform a fireworks show. Different types of
fireworks need to fire at different intervals and delays. They each need to travel to
a different height, and different types of fireworks have different explosion effects
and colors.
1. Would a larger firework show be too intensive? Why or why not?
2. Would web workers help make it more fluid? Why or why not?
Objective summary
Web workers allow the JavaScript runtime to provide multithreading.
Web workers can have sub-workers.
The number of workers that you can use is limitless, but too many workers can hinder
Web workers can receive a single parameter containing any data needed for the
Web workers don't have access to the DOM of the calling page.
Use setTimeout to delay before running a script function. Use setInterval to repeat a
script function after every specified interval.
Objective review
Which of the following isn't a valid web worker operation?
A. postMessage
B. onmessage
C. close
D. terminate
Search WWH ::

Custom Search