Socialcast Learn About Socialcast

Deployment Best Practices

The basic JavaScript snippet works well for individual pages and proof–of-concepts, but deploying Reach across an entire intranet requires a more organized approach. For the best results, we recommend you use the following strategies.

Asynchronous JavaScript Loader

Every JavaScript snippet calls the standalone, asynchronous JavaScript loader:

(function(){
  var e = document.createElement('script'); e.type='text/javascript'; e.async = true;
  e.src = document.location.protocol + 'your-socialcast-domain/services/reach/extension.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s);
})();

Reach is designed to handle multiple asynchronous loads of the extension.js file without negatively impacting performance or functionality. However, for advanced Reach implementations, you can limit duplication and reduce the amount of code required for each snippet by including the loader code in reusable page templates that appear on multiple pages throughout the system.

Application Helper Method

The majority of the JavaScript snippet is overhead shared by all Reach Extensions. You can streamline your code by creating an application helper method, such as create_reach_extension(options), that accepts token and container options and constructs the remainder of the snippet from a common template. Then you can replace the full Reach snippet with a call to the new helper method.