My code is working in preview, but no working when published.

Ok, i think i was on the wrong way, with my suggestion.

Did you connect all your export functions in your Wix-Ui ?
I do not use the js.files, so i think i can’t really help in this case.

And i also do not know, why you should put this code into the js-file and not into the normal page-code-section.