JS Codegen & WebAPI transitioning to ECMA6

The DWScript JavaScript code generator is now transitioning to ECMA6, as the the LTS versions of browsers are now completing the transition. So you will now see the code generator using “let” and other ECMA6 constructs where they make sense, in terms of performance or compacity.

Performance-wise, initial tests indicate there is not much to be gained from ECMA6 code over older code. The gains are rather on the ability to bypass libraries like jQuery, or to leverage Promises in some special cases. One special case, which is rather commonly encountered, is an ajax call handling a JSON response.

At the same time I am taking the old WebAPI library out of its slumber, to expose and leverage ECMA6 and modern browser APIs. The purpose of WebAPI is to expose browser features in a semi-strongly typed fashion. Vast swaths of JS features just were not designed for strong typing, so sticking to a pure & complete approach would make everything quite tedious.

The WebAPI6 also includes a collection of helpers, exposing jQuery-like fluent methods for instance, or simplified “fetch” functions for common use cases. These are intended to be lightweight and “plug” the gaps in ECMA6 functionality or unnecessary complexity.

The BeginEnd.net website is already used as a guinea pig for this effort, with most of the “.pas.js” having already transitioned to use the new WebAPI6 in place of jQuery. The remaining tidbits are those tied to bootstrap 3. When the site will have been transitioned to bootstrap 5, none should remain.