These v19 docs are archived 🔒.
Go to the
latest docs home
or try if
this exact page is available
in the latest docs.
JavaScript in the Browser
The JavaScript which the browser receives can come from multiple sources:
- App Assets located in your App folder
- CDN (Content Delivery Network) - this is often used for common JS libraries
Asset Recommendations
- In general you should bundle and pre-optimize any JavaScript / Typescript code using automations such as WebPack for best possible performance.
- Use Asset Optimizations
- Where possible, use CDNs for common libraries
- Try to use deferred loading for JS and CSS where possible
JavaScript Recommendations
- Point your JS to target the HTML DOM you created in your templates
- Create dynamic JavaScript or Styles based on values in the data #todoc
- Pass CMS data (content-items) to scripts
- using inline JSON
- using HTML attributes
- using REST APIs to get data / content-items
- the JSON format of data in the APIs #todoc
History
- Added in 2sxc 1.0