Skip to content

Limit our dirty javascript global scope

We currently have 149 user defined objects/functions on the window object. You can run this code to see all of our defined stuff.

We really need to clean this up as best as we can. Lot's of plugins. Good way to find out what we still need to use or not.

(function () {
    var results, currentWindow,
    // create an iframe and append to body to load a clean window object
    iframe = document.createElement('iframe');
    iframe.style.display = 'none';
    document.body.appendChild(iframe);
    // get the current list of properties on window
    currentWindow = Object.getOwnPropertyNames(window);
    // filter the list against the properties that exist in the clean window
    results = currentWindow.filter(function(prop) {
        return !iframe.contentWindow.hasOwnProperty(prop);
    });
    // log an array of properties that are different
    console.log(results);
    document.body.removeChild(iframe);
}());

cc @iamphill @alfredo1 @connorshea @annabeldunstone @fatihacet @lbennett et al.