How to encrypt javascript in webflow?

Dear everyone, i would like to ask about webflow
I want to custom script in webflow project but when I published and ( inspect F12 ) it show my script that I embed so the question is “How to hide or encrypt the javascript code in webflow”?

Thank you, Best regard

Hi Yoeun, you cannot encrypt JS, or the browser couldn’t run it.
The best you can do is obfuscate it. You can find some tools to do that, before you past your code or links in.

Just be aware that for someone determined enough, there are tools to “de-obfuscate” that code too.

Best practices are;

  • don’t use client-side JS for any code you don’t want people to see ( or modify in their browser ).
  • never ever ever ever put any form of secrets like API keys in your client-side JS

Yes, but my project uses for loan calculator so how to hide the JS code in my webflow?

You don’t. Is the calculation some kind of trade secret for your client?
If so you need to approach this differently - you do the calculation server-side, and you call it from the webpage when you need to do a calc, get the response and display it how you like.

The calculation is hidden from the world then.

If you need to do that, and aren’t sure how to approach it, I generally program these using Netlify serverless functions or Cloudflare reverse proxy setups. You can run either of these at no month cost.

If there is a lot of data involved in the calculation, you might consider a more comprehensive ( and expensive ) platform like Xano.

Drop me a line if you need a dev to help build this.

ohh so I need to host the script from server and then embed code as link right ?

No. You need to build an API so that the code runs on the server itself.
You’ll call it, pass in your request data, get your response data, and display it.