Eight Simple Rules for Running Your JavaScript on My Page

Kent Brewster (Pinterest)
Presentation: external link
Average rating: ****.
(4.58, 26 ratings)

Third-party JavaScript widgets add functionality and enhance user experience to Web sites, with a very low perceived barrier to entry.

Appearances are deceiving, however. Since JavaScript runs with full access to the document, it must be tightly controlled to prevent it from defacing its surrounding page, stealing the reader’s secrets, or otherwise interacting in an unpredictable fashion with its surroundings, which may include other third-party scripts or browser plug-ins.

To be covered in this talk:

  • including third-party scripts
  • passing configuration variables from the surrounding page to the included script
  • creating and inserting structural elements (HTML), styling (CSS), and behaviors (JavaScript)
  • avoiding interference with existing (and future) page elements
  • requesting and rendering data from external APIs
  • detecting and avoiding interference from other third-party scripts or outside manipulation

... all without increasing perceived load time, stealing event listeners, or creating visible global variables.

Photo of Kent Brewster

Kent Brewster

Pinterest

You may already be running some of Kent Brewster’s difficult-to-detect JavaScript, which powers portions of Yahoo’s Pipes badges, Netflix’s widgets, the Identi.ca badge, and Lexity’s store instrumentation.

Comments on this page are now closed.

Comments

Picture of Kent Brewster
Kent Brewster
06/04/2012 11:00pm PDT

Slides are up at kentbrewster.com/fluent-2012, with expanded variable names in the example code. Thanks again for having me!

Picture of Kent Brewster
Kent Brewster
05/30/2012 10:08pm PDT

Thanks, folks. Best audience I have ever had; would love to come back if possible.

Russell Uman
05/30/2012 6:30pm PDT

This was the best session I attended today, and my only 5 star rating. Having said that,

MANY people (even in other sessions!) took exception to Kent’s practice of using single-character variable/function names. Kent’s excuse, drastically paraphrased: “It works for me”.

What works for you is the last thing that matters when you’re writing code that you expect other people to read.

It is beyond the last thing that matters when you are presenting code at a conference that you want people to be able to comprehend quickly, on a projector screen (in a room that’s too small with a column in the middle obstructing the view).

Please fix this if you deliver this (awesome, entertaining, informative, etc.) presentation again!

Melanie Archer
05/30/2012 5:52pm PDT

Very lively and humorous (important qualities for afternoon session); good use of object literal syntax.

Sponsors

  • appendTo
  • Enyo
  • Ludei
  • Sencha
  • Appcelerator
  • Twitter
  • Infragistics
  • Code For America
  • DevChix
  • Eclipse Foundation
  • Women Who Code

For information on exhibition and sponsorship opportunities at Fluent conference, contact Gloria Lombardo at (203) 381-9245 or glombardo@oreilly.com.

For information on trade opportunities with O'Reilly conferences contact mediapartners
@oreilly.com

View a complete list of Fluent contacts