I wrote this in cfm:
and observed that the script tag is generated containing the following code:
globalDivStruct = null; var _$test_func = function () { var self = this; var variables = {}; self.test = function () { var localdivstruct = globalDivStruct; var __output_var = ""; localdivstruct.outputvar += variable1; variable1 = 20; localdivstruct.outputvar += variable1; return "" }; self.__init = function () { var localdivstruct = globalDivStruct; var __output_var = ""; var tmpVarArray = {}; variable1 = 10; test(); return "" } }; function __startPage__$test() { document.write("\x3cdiv id\x3d'__cfclient_0'\x3e\x3c/div\x3e"); window.ispgbuild = false; var clientDivStruct = { divId: "__cfclient_0", outputvar: "" }; globalDivStruct = clientDivStruct; try { _$test = new _$test_func; _$test.__init() } catch (__eArg) { if (__eArg !== "$$$cfclient_abort$$$") throw __eArg; } __$cf.__flush(clientDivStruct) } __startPage__$test(); function test() { return _$test.test() };
As you can see, the code is not optimized. Is there anyway to tell ColdFusion to optimize the code before returning the response? Also, can the optimization engine be specified i.e. closure, uglify etc.