Chapter 1. Introduction to third-party JavaScript
Figure 1.1. Websites today make use of a large number of third-party services.
Figure 1.2. A script-loading snippet placed on the publisher’s web page loads third-party JavaScript code.
Figure 1.3. An example commenting section on a publisher’s website, powered by the Disqus commenting widget
Figure 1.4. Crazy Egg’s heat map visualization highlights trafficked areas of publishers’ websites.
Figure 1.5. At the bottom of Jill’s resume, the visitor can see friends they share with Jill.
Figure 1.6. Embedding Facebook content in a website using client-side JavaScript
Figure 1.7. The weather widget as it will appear on a publisher’s page
Figure 1.8. A server application dynamically generating the Weather Nearby widget code (widget.js)
Figure 1.9. Failed cross-domain AJAX request from localhost to google.com in Google Chrome
Chapter 2. Distributing and loading your application
Figure 2.1. The feature-complete Camera Stork product widget
Figure 2.2. Each virtual host points to a separate folder in your filesystem.
Figure 2.3. Two scripts (A and B) loaded using both the defer and async attributes. Files loaded with the async attribute execute as soon as they’re downloaded, whereas files loaded with defer wait until the document is fully parsed.
Figure 2.4. High-level application flow for widget.js
Figure 2.5. The loadScript function loads a JavaScript file from the provided URL and invokes a callback function when that file is ready.