Skip to content

Migrating Seaside Javascript wrappers to 3.6.0

Johan Brichau edited this page Dec 24, 2025 · 2 revisions

Seaside 3.6.0 changed the implementation of the Javascript code generation to use a canvas with brushes instead of writing characters onto a stream. While the existing API of the JSObject hierarchy for Javascript generation remains unchanged, developers of Javascript wrappers or any Seaside user who implements javascriptContentOn: or javascriptOn: methods needs to migrate their implementation of these methods from a Stream type argument to a JSCanvas type argument.

Why was this changed?

Prior to 3.6.0, Javascript generation was performed on an intermediate String instance which was then written onto the response document. The creation of an intermediate String is now avoided which improves memory use and the response speed. In particular when generating JQuery DOM manipulation scripts, the generated Javascript code often includes large strings with embedded html. This change also allowed to move the implementation of the Javascript string encoding (which was located on the JSStream class) to the WAEncoder hierarchy, contributing to a more uniform implementation of escaping/encoding of html, Json and Javascript in Seaside.

Migration Guide

Review and change all your custom implementations of javascriptOn: and javascriptContentOn: to use JsCanvas type argument.

If this is your original method implementation that writes to aStream:

javascriptContentOn: aStream

	"original code writing to aStream"

You can patch it as follows, quick-and-easy:

javascriptContentOn: aJsCanvas

	aJsCanvas javascript: (String streamContents: [:aStream | "original code writing to aStream" ])

But that will again create an intermediate string. This might not be an issue in your case, so it could be perfectly fine. If your generated string can be large, then consider using the JsJavascriptCanvas api to adapt your existing code to a canvas-with-brushes implementation. You can check out the example javascriptContentOn: methods for JsObject as an inspiration.

Clone this wiki locally