This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _reach = _reach || []; | |
_reach.push({ | |
container: 'corp_stream', | |
domain: 'http://socialcast.com/', | |
token: '12345' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
// Private (not accessible in global scope) | |
function UtilityFunction(){} | |
function ThirdPartyAPI(){} | |
// Export a single global access point the ThirdPartyAPI | |
window.thirdPartyAPI = window.thirdPartyAPI || new ThirdPartyAPI(); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var e = document.createElement('script'); e.type='text/javascript'; e.async = true; | |
e.src = document.location.protocol + '//yourdomain.com/packaged_third_party_javascript.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate a Component | |
var newComponent = new Component({ | |
// Init creates domElement and associatedElements properties | |
// Override removeElement method | |
removeElement: function(){ | |
this.domElement.remove(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------------- | |
// Excerpt from jQuery's cleanData() (MIT Licence) | |
// Embrace circular references in event bindings, but clean up. | |
if ( data && data.events ) { | |
for ( var type in data.events ) { | |
if ( special[ type ] ) { | |
jQuery.event.remove( elem, type ); | |
} else { | |
jQuery.removeEvent( elem, type, data.handle ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MS example of a memory leak "caused by closure" | |
hookup(document.getElementById('menu')); | |
function hookup(element) { | |
// Reference to #menu element available within | |
// mouse scope via closure | |
function mouse (){} | |
// mouse attached to #menu element via event. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate a Component (overriding removeElement method) | |
var newComponent = new Component({ | |
removeElement: function(){ | |
this.domElement.remove(); | |
this.trigger('removeElement'); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove the message from the Cache | |
// Must explicitly null out this reference for IE GC | |
messagesCache[messageID] = null; | |
delete messagesCache[messageID]; |