Assume you have your SSJS written as an object like so inside a Content Block:
var SFMC = {
multiply: function (p1, p2) {
return p1 * p2;
}
}
var SFMC = {
multiply: function (p1, p2) {
return p1 * p2;
}
}
You can pull it into a CloudPage or anywhere else by using:
<script runat = "server" type="text/javascript">
Platform.Load("Core", "1");
var SFMC = eval(Platform.Function.ContentBlockByID('YOUR_CONTENT_BLOCK_ID'));
</script>
<script runat = "server" type="text/javascript">
Platform.Load("Core", "1");
var SFMC = eval(Platform.Function.ContentBlockByID('YOUR_CONTENT_BLOCK_ID'));
</script>
Then you can make use of the function like so:
<script runat = "server" type="text/javascript">
Platform.Load("Core", "1");
var SFMC = eval(Platform.Function.ContentBlockByID('YOUR_CONTENT_BLOCK_ID'));
var result = SFMC.multiply(1,2);
</script>
<script runat = "server" type="text/javascript">
Platform.Load("Core", "1");
var SFMC = eval(Platform.Function.ContentBlockByID('YOUR_CONTENT_BLOCK_ID'));
var result = SFMC.multiply(1,2);
</script>