Rich-text Reply

Type Inference and Performance

johnhenryenvy 06-26-15

Type Inference and Performance

I have some code that looks like this:


var init = function(main, options){

which runs fine, but the Optimizely editor keeps telling me that "main is not a function". I understand how it's coming to this conclusion, but it is clearly wrong in this case (seeing how it works, and all...).

Here are's my question: 


Does Optimizely discourage this style of programming for any specific of reason?


Does it affect the way  the snippit is compiled?

Does this cause performance issues of which I am not aware?

(I ask these two questions because I am aware that some of Javascript's more "advanced" features can degrade performance in V8 (Chrome, Node) due to the way it's compiled)


Finally, if not, is there a way to disable error checking in the Optimizely editor? (I've hade more than one experience where perfectly valid code has thrown an "error", scaring a client and causing a delay in launch.) 


Please be thorough.



moravemj 06-26-15

Re: Type Inference and Performance

Hey @johnhenryenvy,


The Optimizely edit code box error checker is a modified version of JS Hint. Are you seeing that error in the edit code box, experiment javascript, or project javascript? I added the code to all three and it didn't give me any errors there. 


There is not a way to disable error checking in the Optimizely editor right now. 


Happy Friday!



Aicke 06-30-15

Re: Type Inference and Performance

[ Edited ]

Regardless of the javascript errors (I often get them, too) your code will not execute until domready, which may result in page flashing.


I suggest you to take a look at:

Everything is hard, before it is easy.
Level 2