You are previewing Third-Party JavaScript.
O'Reilly logo
Third-Party JavaScript

Book Description

Summary

Third-Party JavaScript guides web developers through the complete development of a full-featured third-party JavaScript application. You'll learn dozens of techniques for developing widgets that collect data for analytics, provide helpful overlays and dialogs, or implement features like chat or commenting. The concepts and examples throughout this book represent the best practices for this emerging field, based on thousands of real-world dev hours and results from millions of users.

About this Book

There's an art to writing third-party JavaScript—embeddable scripts that can plug into any website. They must adapt easily to unknown host environments, coexist with other applications, and manage the tricky security vulnerabilities you get when code and asset files are served from remote web addresses. Get it right and you have unlimited options for distributing your apps. This unique book shows you how.

Third-Party JavaScript guides you through the ins and outs of building full-featured third-party JavaScript applications. You'll learn techniques for developing widgets that collect data for analytics, provide helpful overlays and dialogs, or implement features like chat and commenting. The concepts and examples throughout the book represent the best practices for this emerging field, based on thousands of real-world dev hours and results from millions of users.

Written for web developers who know JavaScript, this book requires no prior knowledge of third-party apps.

What's Inside

Writing conflict-free JavaScript, HTML, and CSS Making cross-domain requests from the browser How to overcome third-party cookie limitations Security vulnerabilities of third-party applications

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Authors

Ben Vinegar is an engineer at Disqus, a third-party JavaScript commenting platform. Anton Kovalyov is a software engineer at Mozilla. They are third-party applications experts whose work has been distributed on millions of websites

Table of Contents

  1. Introduction to third-party JavaScript

  2. Distributing and loading your application

  3. Rendering HTML and CSS

  4. Communicating with the server

  5. Cross-domain iframe messaging

  6. Authentication and sessions

  7. Security

  8. Developing a third-party JavaScript SDK

  9. Performance

  10. Debugging and testing

Table of Contents

  1. Copyright
  2. Brief Table of Contents
  3. Table of Contents
  4. Foreword
  5. Preface
  6. Acknowledgments
  7. About this Book
    1. Roadmap
    2. Code conventions and downloads
    3. Author Online
  8. About the Authors
  9. About the Cover Illustration
  10. Chapter 1. Introduction to third-party JavaScript
    1. 1.1. Defining third-party JavaScript
    2. 1.2. The many uses of third-party JavaScript
    3. 1.3. Developing a bare-bones widget
    4. 1.4. Challenges of third-party development
    5. 1.5. Summary
  11. Chapter 2. Distributing and loading your application
    1. 2.1. Configuring your environment for third-party development
    2. 2.2. Loading the initial script
    3. 2.3. The initial script file
    4. 2.4. Loading additional files
    5. 2.5. Passing script arguments
    6. 2.6. Fetching application data
    7. 2.7. Summary
  12. Chapter 3. Rendering HTML and CSS
    1. 3.1. Outputting HTML
    2. 3.2. Styling your HTML
    3. 3.3. Defensive HTML and CSS
    4. 3.4. Embedding content in iframes
    5. 3.5. Summary
  13. Chapter 4. Communicating with the server
    1. 4.1. AJAX and the browser same-origin policy
    2. 4.2. JSON with padding (JSONP)
    3. 4.3. Subdomain proxies
    4. 4.4. Cross-origin resource sharing
    5. 4.5. Summary
  14. Chapter 5. Cross-domain iframe messaging
    1. 5.1. HTML5 window.postMessage API
    2. 5.2. Fallback techniques
    3. 5.3. Simple cross-domain messaging with easyXDM
    4. 5.4. Summary
  15. Chapter 6. Authentication and sessions
    1. 6.1. Third-party cookies
    2. 6.2. Setting third-party cookies
    3. 6.3. Securing sessions
    4. 6.4. Summary
  16. Chapter 7. Security
    1. 7.1. Cookies, sessions, and session theft
    2. 7.2. Cross-site scripting
    3. 7.3. Cross-site request forgery
    4. 7.4. Publisher vulnerabilities
    5. 7.5. Summary
  17. Chapter 8. Developing a third-party JavaScript SDK
    1. 8.1. Implementing a bare-bones SDK
    2. 8.2. Versioning
    3. 8.3. Wrapping web service APIs
    4. 8.4. Summary
  18. Chapter 9. Performance
    1. 9.1. Optimizing payload
    2. 9.2. Optimizing JavaScript
    3. 9.3. Perceived performance
    4. 9.4. Summary
  19. Chapter 10. Debugging and testing
    1. 10.1. Debugging
    2. 10.2. Testing
    3. 10.3. Summary
  20. Index
  21. List of Figures
  22. List of Tables
  23. List of Listings