guardian/frontend — pull request #212 by ahume (2012-11-05 12:01:05+00:00)
Title: Audience science (AS)

What does this do? It adds two extra JS requests to a third party for every page load, totalling about 6Kb gzipped.

In the adverts module when ads start getting created we call audienceScience.load(). This sets up a couple of functions on our window object and then makes an async call to a JS file hosted by AS. This file calls those global functions to gather some config, etc, and then makes another http request that eventually callsback another function on window, passing audience segmentation data. This is stashed in localStorage and used for the next ad calls (which may be the next page if they've already been made (we don't queue them up behind AS).

I also added a cookies module, with one purpose. Deleting cookies. This is currently called in the bootstrap to remove some legacy R2 cookies (that haven't been cleaned up well yet), as well as in the ausience-science module to remove a cookie that AS sets (and that we don't need as we use localStorage).