Internal JavaScript API

In my opinion, Webflow is by far the website builder that allows you the most customizability, but there are still grey areas in which Webflow can not natively deliver the desired front-end. In a situation like this, custom code usually comes to the rescue.


However, adding custom code whilst using dynamic components such as CMS lists can become quite ineffective as you will sometimes be forced to render the component on the page for you to get the required data (yes, Webflow does support CMS-list-fields in its custom code, but if you require anything more than that you are screwed).


For this reason, adding an internal JS API that does NOT require you to make external HTTP requests, would make life much easier when creating custom components from scratch. As I see it, the API could work one of 2 ways:


  • The Designer gets a new element added that allows you to select what CMS items you want to “export” to the JS API. This element could much like CMS lists be filtered, sorted, and so on. On the published site, custom code could then call the API (much like you use document.XXXXXXX) and from there retrieve the desired information as a JSON object or similar.


  • In CMS collection settings, you could add the ability to “export CMS collection to API”. The CMS collection would then be available through an internal JS API such as mentioned above.



EXAMPLE:

Currently, Webflow does not support CMS sliders and because you can not fetch an entire collection list in the custom code, you have to do the following to create a CMS slider:


  1. Add a hidden CMS list in the designer with the desired items you want available in the CMS slider.

  2. Add an empty slider to the page

  3. Through custom code, copy the elements in the CMS list and add them to the slider

  4. Delete or hide the CMS list


With the addition of an internal JS API, you would no longer be required to saturate the page with HTML elements that are in reality only there to display data used to create the elements needed for the slider.


Furthermore, adding an internal JS API would allow for further processing of CMS data (and other data if implemented).

  • Bonzer
  • Aug 4 2023
  • Pranav commented
    August 19, 2023 12:33

    I faced similar kind of issues.