Skip to content

Instantly share code, notes, and snippets.

@dangerouse
Last active March 8, 2016 22:55
Show Gist options
  • Save dangerouse/2163217 to your computer and use it in GitHub Desktop.
Save dangerouse/2163217 to your computer and use it in GitHub Desktop.
Cloudsponge Widget Reference - Asynchronous Loading
<!DOCTYPE html>
<html>
<body onload="loadHandler()">
<script type='text/javascript'>
// Replace the stylesheet with a valid value.
// basic csPageOptions, this variable can be defined anytime before the
// CloudSponge widget has initialized
window.csPageOptions = {
textarea_id:'contact_list',
};
// Adds the CloudSponge javascript script tag to the page
function includeCloudSponge() {
var first_script = document.getElementsByTagName('script')[0];
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', "//api.cloudsponge.com/widget/YOUR_WIDGET_SCRIPT.js");
first_script.parentNode.insertBefore(s, first_script);
}
// Called when the body of the document has loaded
function loadHandler() {
// Perform initialization here that must start immediately
// ..
// Load resources that don't need to be there right away
// ..
// Include CloudSponge after the time-critical initialization is complete
includeCloudSponge();
}
</script>
<a class="cs_import">Add from Address Book</a>
<textarea id="contact_list" style="width:450px;height:82px"></textarea>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment