Since version 1.6 (i.e. a long time ago) Java has had a built-in JavaScript engine. Called Rhino in Java 1.6-1.7 and replaced by Nashorn in 1.8, the JS engine has always been reliable (it’s the user-facing script language of numerous Java-based commercial apps) even if its function set and performance lags behind browsers’ JS engines.

This means if you have a ready-made JS snippet that does what you want, and you don't want to learn Velocity and/or translate your JS into native Java methods (hint: you eventually should learn how to tie Velocity in with raw Java, you'll be more productive for it) then you can sneak JS inside your Velocity token and get your cool email personalizations out the door.

You'll be running JavaScript, inside Velocity, inside Java, all inside Marketo: it's pretty darn cool, even if not something to lean on permanently.

Here's an example Velocity script which has JS do the heavy lifting…

 

 

Read the full post on TEKNKL :: Blog →