Q:

How to fix CAMLJS undefined error?

I am running a simple CamlJs, it works from Chrome Console and from the Chrome Extension. However when I try from a Content Editor Webpart (Sharepoint Online / O365) it gives me an error.
<script src="/sites/intranet/Style%20Library/CI/scripts/document_library/camljs.js"></script>
<script type="text/javascript">       
 var str = new CamlBuilder()
            .Where()
            .LookupMultiField("Tag")
            .IncludesSuchItemThat()
            .ValueAsText()
            .In(['a', 'b', 'authorization form'])
            .ToString();
console.log(str);
</script>

This is the error:
camljs.js:948 Uncaught TypeError: Cannot read property 'create' of undefined
    at Builder.Finalize (camljs.js:948)
    at QueryToken.ToString (camljs.js:304)
    at doclib.aspx:1123

A:

Try to put your code inside SP.SOD.executeOrDelayUntilScriptLoaded block.
camljs uses some functions which are not availiable on document load.  
SP.SOD.executeOrDelayUntilScriptLoaded(function(){
var str = new CamlBuilder()
            .Where()
            .LookupMultiField("Tag")
            .IncludesSuchItemThat()
            .ValueAsText()
            .In(['a', 'b', 'authorization form'])
            .ToString();
console.log(str);  
}, 'sp.js');

