Explainer
Where JavaScript and WebAssembly Actually Run on an HMI
Short answer
JavaScript and WebAssembly execute in the HMI client's browser engine — the panel itself, a panel PC, or a desktop browser — never inside the PLC, which only serves the files and exposes data through a documented interface. Decide on the rendering route the installed runtime provides, then verify rendering, module execution, and the data path in that order.
On this page
- Does the JavaScript run on the PLC or on the HMI screen?
- Which browsers can run WebAssembly?
- How do I tell which runtime renders my HMI screen?
- Which route fits a custom web application?
- How do I verify the panel runs my JavaScript and WebAssembly?
- How does the displayed value connect to the controller?
- What should never run in the browser application?
- Questions asked
JavaScript and WebAssembly run in the browser engine of the HMI client — the panel itself, a panel PC, or a desktop browser — and never inside the PLC. The controller's job ends at serving files and exposing data through a documented interface, which is why an announcement about JavaScript on HMI screens is really an announcement about the client. This article answers the questions in the order you meet them: what executes where, which browsers have WebAssembly, how to identify the rendering client, which route fits your code, and how to verify rendering, module execution, and the data path with real numbers before the machine is involved.
Does the JavaScript run on the PLC or on the HMI screen? #
JavaScript and WebAssembly execute in the browser engine of whichever client displays the screen — the HMI panel, a panel PC, or a desktop browser — never inside the PLC, whose web server only hands the files to that client. The control program runs on the controller's scan: no document object model, no layout engine, no page event loop, so nothing in the PLC compiles or interprets your scripts. Vendors document this split openly. Siemens, for example, describes the SIMATIC S7-1200 G2 built-in web server as serving pages built with HTML, JavaScript and jQuery, reached through a PLC Web API: the controller provides the pages and the data, the client renders them. Compiling your C# to WebAssembly moves the computation to the client as well. The decision: treat the application as a browser application and the controller as a file host plus data endpoint, and design everything from that split.
Which browsers can run WebAssembly? #
Core WebAssembly compiles in Chrome 57 and later, Firefox 52 and later, Safari 11 and later, Edge 16 and later, Opera 44 and later, and Samsung Internet 7.2 and later; Internet Explorer never gained it. The engines behind those version numbers are the ones doing the work in the client: V8 sits behind Chrome and Opera, SpiderMonkey behind Firefox. Standalone runtimes such as Wasmtime execute modules outside a browser entirely — that is what an edge host would use, never a PLC. These thresholds cover the core format; advanced features vary by engine and version, so the panel itself remains the test bed even when documentation clears it. Read the panel's engine and version in its documentation: at or above the threshold, the core module compiles; where the documentation names Internet Explorer, WebAssembly is not available on that panel at all. When the engine is fixed below the threshold and cannot be updated, the browser moves to a host that can run it: industrial panel PCs put a current desktop browser at the machine while the controller keeps serving the files.
How do I tell which runtime renders my HMI screen? #
Read the panel's model and installed runtime from the device configuration or the engineering project, then identify which of three clients opens your screen: a browser page, a vendor web-visualization client, or another HMI runtime. Work it down to facts:
- Read the panel model and its installed runtime from the device configuration or the engineering project.
- Establish what actually opens the screen: a web address in a browser, the vendor's web-visualization client, or another HMI runtime.
- For the announced JavaScript feature, find its documentation and read four things: the execution context, the supported APIs, the deployment method, and the restrictions.
- If the client is a browser, note its engine version and check it against the browser thresholds.
The client is not always the operator terminal. The same served application can be displayed by a separate panel PC acting as the browser host; running a PLC-hosted visualization on a remote HMI panel PC covers that arrangement. And treat an announcement as a pointer to documentation, not a specification: the words runs JavaScript say nothing about where the code executes or which interfaces it can reach until the runtime documentation says so.
Which route fits a custom web application? #
Serve your HTML, CSS, and JavaScript from the controller's built-in web server when the application already exists; use the vendor's web-visualization package when you want a visual editor; host on an edge device when the app needs its own platform. That is the whole route decision, and it looks like this:
| Route | Configured in | Choose it when |
|---|---|---|
| Controller web server | Web-server settings and the application files on the controller | The application already exists and needs hosting plus a data interface |
| Vendor web-visualization package | The visualization project and the client configuration | You want a visual editor and do not need to own the browser code |
| Integration package for custom pages | The package configuration and its documented integration interface | You own the HTML, CSS, and JavaScript and want a supported data path |
| Edge-device hosting | Application deployment on the edge platform | The application needs services of its own — containers, storage, a local database |
For a conventional machine HMI, take the visual-editor package unless its widgets cannot express your screen; you exchange ownership of the code for something controls staff can maintain. For an existing web application, host it on the controller's web server and use the documented data interface, stepping up to the integration package when you need vendor-supported data access for pages you own. Move hosting to an edge device only when the application needs its own platform services. Read the installed packages' documentation and licensing terms before committing to any of the three.
How do I verify the panel runs my JavaScript and WebAssembly? #
Load a minimal page that JavaScript visibly updates on the panel itself, because a desktop-browser test proves nothing: the panel's engine may be older than Chrome 57 or Firefox 52, the versions where WebAssembly begins. Verify in two layers here, each on the target panel, and add the data path in the next section.
- Rendering. Load a minimal page that JavaScript visibly updates — a label whose text the script changes on load. If the text does not change on the panel, nothing downstream will work; fix the client before touching the application.
- Module execution. Build the smallest application your browser-targeted toolchain supports, deploy its complete output with the server's documented procedure, and confirm the page, scripts, module, and supporting assets load from their expected addresses. Then prove the module: have it export one function that returns 7 × 6 and display the result — the panel must show 42.
If the panel shows 42, the module compiled, instantiated, and handed its result back through JavaScript. A blank page at this stage is a missing asset, a wrong address, or a script exception — a failure that exists entirely before any PLC connection. Failed requests and script exceptions appear in the browser's diagnostics; read them before changing anything on the controller side.
How does the displayed value connect to the controller? #
Rendering and machine-data access are two separate connections: the page loads from the web server, while values arrive through the data interface the visualization or integration package documents — one can work while the other fails. Select that documented interface, expose one read-only value with a known meaning, data type, and engineering unit, and watch it in the controller's online monitoring tools before connecting anything visual.
Worked example. The controller exposes a read-only 16-bit INT scaled so 0–32767 counts span 0.0–300.0 °C, and online monitoring shows 12345. The screen must display:
12345 ÷ 32767 × 300.0 = 0.37675 × 300.0 = 113.0 °C
Agreement is three-point: the controller monitor reads 12345, the application receives 12345, and the screen shows 113.0. Advance only when all three match.
| Observed condition | Check first | Fault boundary |
|---|---|---|
| The controller value changes but no new data reaches the application | Communication diagnostics, endpoint and subscription settings | Connection or access fault |
| The application receives the correct value but the screen does not change | Widget binding and page logic | Binding or rendering fault |
| The screen updates with the wrong magnitude or format | Data conversion, scaling, and display format | Type or engineering-unit mismatch |
A clean factor of ten is the tell: 11.3 instead of 113.0 means the scaling, not the connection, is wrong — scaling a PLC integer into an HMI display value works through that class of fault.
What should never run in the browser application? #
Time-critical control and safety functions stay in the controller, always: the browser path adds web-server, network, and page-rendering delays that no HMI screen logic is designed to bound. Interlocks, motion stops, and anything the machine must act on within its scan belong in the controller's program, where the timing is deterministic. Put presentation in the client — display, validated entry, local math for how values are shown — and compute in the controller anything the machine acts on, displaying only the result. That division is the one safety rule here, and it is not negotiable at the screen.
Questions asked
Do I need to learn structured text to display my web application on an HMI?
No. The screen is rendered by a browser, so HTML, CSS, JavaScript, and WebAssembly skills transfer directly. What does need control-system work is the data side: every variable your page reads or writes must exist on the controller with a defined name, data type, and access rights, and someone has to declare and expose it there before the page can show anything real.
Can I copy my compiled C# program onto the controller's web server?
No. A desktop or server executable is not a browser artifact and will not load. A browser-targeted toolchain produces a WebAssembly module together with a runtime and supporting assets, and the complete output must be deployed as a set. If the server hands out the module with the wrong content type, loading stops there, and the browser's diagnostics show the failed request before any of your code runs.
Why does my application work in Chrome on a desktop but stay blank on the panel?
Because the panel runs a different browser engine than your desktop. Core WebAssembly needs Chrome 57, Firefox 52, Safari 11, Edge 16, Opera 44, or Samsung Internet 7.2 and later, and an embedded Internet Explorer engine never gained it at all. Check the panel's documented engine and version first; a blank page can also come from a missing asset or a script exception, both of which appear in the browser's diagnostics.
Is WebAssembly useful for industrial IoT applications at the machine?
Yes, at the screen. A module is well suited to local computation in the client — unit conversions, trend math, presentation logic — because it runs at the panel without loading the controller. It is not a place to compute anything the machine acts on: values that feed control or safety must be produced inside the controller's program, on its scan, with the screen only displaying the results.