Table of Contents

JavaScript in the Browser

you are here (click to zoom) - discover the stack

The JavaScript which the browser receives can come from multiple sources:

  1. App Assets located in your App folder
  2. CDN (Content Delivery Network) - this is often used for common JS libraries

Asset Recommendations

  1. In general you should bundle and pre-optimize any JavaScript / Typescript code using automations such as WebPack for best possible performance.
  2. Use Asset Optimizations
  3. Where possible, use CDNs for common libraries
  4. Try to use deferred loading for JS and CSS where possible

JavaScript Recommendations

  1. Point your JS to target the HTML DOM you created in your templates
  2. Create dynamic JavaScript or Styles based on values in the data #todoc
  3. Pass CMS data (content-items) to scripts
    1. using inline JSON
    2. using HTML attributes
    3. using REST APIs to get data / content-items
    4. the JSON format of data in the APIs #todoc

History

  1. Added in 2sxc 1.0