How to hide .js files on wordpress website using php or wp plugins or any? [closed]

You can not mix js and php. It seems (sure) that your js script (that was embed in the document), has php in it. That can work if the code is embed in the document as the php tags are open and close correctly.

If you link to a js file, there is no way for it to understand php tags, function…

If you want to add safely some php in a js file, one way is to echo the script in the document (but you don’t want), other way is to enqueue the script and use wp_localize_script() to handle some php var.

If you can show some more code about script.php ?