DWScript features a powerful Pascal-to-JavaScript compiler (dwsJSCodeGen). It allows you to write client-side logic in strongly-typed Object Pascal and deploy it as optimized JavaScript.
SmartLinker analyzes your code and removes unused classes, methods, and types from the final output, significantly reducing bundle size.| Option | Description |
|---|---|
cgoSmartLink |
Enables the Smart Linker. Unreachable code is stripped. |
cgoObfuscate |
Minifies and obfuscates symbol names to protect intellectual property and reduce size. |
cgoPrettify |
Generates readable, indented JavaScript (useful for debugging). |
// Pascal Source
type
TPoint = record x, y : Integer; end;
function Add(a, b : Integer) : Integer;
begin
Result := a + b;
end;
// If "Add" is called, it will be in the JS output.
// If "TPoint" is unused, it will be removed by SmartLinker. Standard libraries like System, Math, and Classes are partially mapped to JS equivalents, allowing for seamless code sharing between server (native) and client (JS).