Applies from version 2.25.10.11061
We have updated our JINT script engine. Previously, we supported ES5, but the new version now uses ES6. This brings new capabilities, but also changes how existing scripts are handled.
What happens when a project is updated?
-
When a project is updated to version 2.25.10.11061, all existing scripts will run using the old Legacy Script Engine.
-
You can gradually update scripts to the new JINT engine, which is recommended. Backward compatibility will be removed in future versions, meaning old Legacy scripts may stop working.
Working with existing scripts
In the script list, there is a "Legacy" column, showing which scripts run in Legacy mode.
This provides a clear overview of which scripts are still using the old Legacy engine.
NOTE!
Changing the engine in the edit view only affects how the script is tested — it does not change which engine the system uses when running the script.
To permanently switch the engine, you must update the setting in the right-hand side menu.
-
Open an existing script for editing
-
Select a script and open it in edit mode.
-
The "Legacy" button is filled by default, indicating that the script runs on old JINT engine (Legacy) when testing the script in edit mode.
-
-
Test the new JINT
-
You can disable "Legacy" by clicking the button in edit mode.
-
This allows you to edit the script and test run it in the new JINT engine.
-
Your changes will not affect original script, click the "Legacy" button again to switch back to editing in Legacy mode.
-
-
Save and exit editing
-
Important: When you save and leave edit mode, the script will continue to run in Legacy unless you disable it.
-
To make the script run on the new JINT engine:
-
Click the script from the list to open the right-hand menu.
-
Unblock "Legacy Script Engine" and save.
-
-
Tip
If a script is not working, it may be because Moldeo.WebPortCommon is no longer available in scripts in the new JINT engine. References to this namespace must therefore be removed.
Example of change:
// Previously (does not work in the new engine)
tags["TAG_NAME_PV"].ReadValue(Moldeo.WebPortCommon.ReadTypes.PRIORITY);
// Updated (correct in the new engine)
tags["TAG_NAME_PV"].ReadValue(ReadTypes.PRIORITY);
New scripts
-
New scripts are always created to run in new JINT engine by default.
- Blockly is not available in the new JINT script engine.
Custom reports
-
The same functionality applies to custom reports:
-
You can work with the script in Legacy mode or test it in new JINT.
-
When ready to run the report in the new script engine:
-
Go to Parameters → General Settings.
-
Unblock "Legacy Script Engine" and save.
-
-
New JINT – Best Practices & Tips
When running scripts in new JINT, using plain JavaScript objects is significantly faster than creating or manipulating C# instances like JArray and JObject.
For comparison, measured execution times for a simple test were:
| Engine | Pure JS objects | C# instances (JArray/JObject) |
| Legacy JINT | 27 ms | 40 ms |
| New JINT | 8 ms | 979 ms |
For optimal performance and maintainability, perform all logic and data handling in pure JavaScript whenever possible.
Example:
const result = [];
const amount = 1000;
const first = benchmark("Pure JS objects", () => {
const items = [];
for (let i = 0; i < amount; i++) {
const item = {};
item.id = Number(i);
item.value = Number(i * 2);
items.push(item);
}
});
result.push(first);
const second = benchmark("C# JObjects", () => {
const JArray = Newtonsoft.Json.Linq.JArray;
const JObject = Newtonsoft.Json.Linq.JObject;
const JValue = Newtonsoft.Json.Linq.JValue;
const items = new JArray();
for (let i = 0; i < amount; i++) {
const item = new JObject();
item.Add("id", new JValue(Number(i)));
item.Add("value", new JValue(Number(i * 2)));
items.Add(item);
}
});
result.push(second);
return result.map(({ label, sw }) => `${label}: ${sw.ElapsedMilliseconds} ms`).join("<br>");
function benchmark(label, fn) {
const sw = new System.Diagnostics.Stopwatch();
sw.Start();
fn();
sw.Stop();
debug(`${label}: ${sw.ElapsedMilliseconds} ms`);
return { label, sw };
}
Info
If you have questions or tips about migrating functions to the new JINT engine, please contact us at support.webport@kiona.com Your feedback helps us improve our guidance and tools.