Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,902 members, 7,802,926 topics. Date: Saturday, 20 April 2024 at 03:36 AM

Need Step On How To Hide Javascript Source Code. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Need Step On How To Hide Javascript Source Code. (2846 Views)

Free PHP, Node js ,Mongo db, Angular And C# Proje Source Code With Documentation / Step By Step On How To Write A Good Blog Post / Javascript Source Code For GPA Calculator (2) (3) (4)

(1) (Reply) (Go Down)

Need Step On How To Hide Javascript Source Code. by Oladg2: 7:52pm On Nov 24, 2016
Need step on how to hide javascript source code .
Re: Need Step On How To Hide Javascript Source Code. by kudaisi(m): 9:18pm On Nov 24, 2016
Oladg2:
Need step on how to hide javascript source code .

There's really no perfect way to absolutely protect you JavaScript source from a user that is determined to see it and experienced enough to know how to go about it. However, I know that you can make it harder for user to view your javascript source (hopefully hard enough to discourage the viewer) .

Some methods include referencing the scripts from external files...i.e breaking the code into bits and pieces within separate files which are equally referencing other files, you can also retrieve some of the scripts via Ajax calls. Additionally, you can obfuscate you code to make it unreadable without hassle.

It's important to note however that I rarely find it necessary to make my javascript secret (its not like I have my database password hardcoded somewhere within the script). Its mostly about getting the script to work at optimum performance.

1 Like 1 Share

Re: Need Step On How To Hide Javascript Source Code. by SeunLanLege(m): 9:55pm On Nov 24, 2016
kudaisi:


There's really no perfect way to absolutely protect you JavaScript source from a user that is determined to see it and experienced enough to know how to go about it. However, I know that you can make it harder for user to view your javascript source (hopefully hard enough to discourage the viewer) .

Some methods include referencing the scripts from external files...i.e breaking the code into bits and pieces within separate files which are equally referencing other files, you can also retrieve some of the scripts via Ajax calls. Additionally, you can obfuscate you code to make it unreadable without hassle.

It's important to note however that I rarely find it necessary to make my javascript secret (its not like I have my database password hardcoded somewhere within the script). Its mostly about getting the script to work at optimum performance.

I load my js asynchronously. So ctrl+u won't show you my code,except you check your network requests in your console. That's the best way I know to hide your js code. It also optimizes page loads.
Re: Need Step On How To Hide Javascript Source Code. by kudaisi(m): 11:32am On Nov 25, 2016
SeunLanLege:


I load my js asynchronously. So ctrl+u won't show you my code,except you check your network requests in your console. That's the best way I know to hide your js code. It also optimizes page loads.

Like I said, AJAX is an option.
Re: Need Step On How To Hide Javascript Source Code. by chido4real(m): 2:24pm On Nov 28, 2016
Oladg2:
Need step on how to hide javascript source code .

You can use one of the javascript obfuscation tools like using uglifyJS with the --mc flag.
Re: Need Step On How To Hide Javascript Source Code. by orimion(m): 8:25pm On Nov 28, 2016
why would you need to hide it? I don't think there is any viable reason
Re: Need Step On How To Hide Javascript Source Code. by Oladg2: 12:32am On Nov 30, 2016
chido4real:


You can use one of the javascript obfuscation tools like using uglifyJS with the --mc flag.



Please how do i go about this ?
Re: Need Step On How To Hide Javascript Source Code. by kudaisi(m): 10:29am On Nov 30, 2016
Oladg2:

Please how do i go about this ?

You need to install Node.js,
Then install UglifyJS with NodeJS package manager
npm install uglify-js -g
To obfuscate a file say scripts.js for example
run the command
uglifyjs --compress --mangle scripts.js
or simply
uglifyjs --mc scripts.js
as earlier mentioned by @chido4real

What you need mostly is the --mangle (--m) option, according to the documentation it Mangle names/pass mangler options. The --compress option also makes it hard to read, but the effect can easily be reversed with a beautifier.
Re: Need Step On How To Hide Javascript Source Code. by kudaisi(m): 10:30am On Nov 30, 2016
Alternatively, you can download http://javascriptobfuscator.com/ GUI and install. If you don't already have Node.js.
FYI: There are some beautifiers out there that can reverse obfuscation.. Maybe not to it's original state, but to a state that is more readable.
Re: Need Step On How To Hide Javascript Source Code. by Oladg2: 2:33pm On Nov 30, 2016
kudaisi:


You need to install Node.js,
Then install UglifyJS with NodeJS package manager
npm install uglify-js -g
To obfuscate a file say scripts.js for example
run the command
uglifyjs --compress --mangle scripts.js
or simply
uglifyjs --mc scripts.js
as earlier mentioned by @chido4real

What you need mostly is the --mangle (--m) option, according to the documentation it Mangle names/pass mangler options. The --compress option also makes it hard to read, but the effect can easily be reversed with a beautifier.

Thanks very much , I all try it out.
Re: Need Step On How To Hide Javascript Source Code. by micodon(m): 7:56am On Dec 01, 2016
You cant hide your client - side js code from anyone who knows what he's doing. The code would eventually get loaded by the user 's browser before it's interpreted and executed. Its a matter of using the network tab in the browser developer tools, getting the script(s) and beautifying if it has been uglified. Your efforts can only work on kids
Re: Need Step On How To Hide Javascript Source Code. by ernieboy(m): 8:36am On Dec 01, 2016
if u need to hide something it should not be on a client side script
Re: Need Step On How To Hide Javascript Source Code. by chido4real(m): 7:26pm On Dec 02, 2016
micodon:
You cant hide your client - side js code from anyone who knows what he's doing. The code would eventually get loaded by the user 's browser before it's interpreted and executed. Its a matter of using the network tab in the browser developer tools, getting the script(s) and beautifying if it has been uglified. Your efforts can only work on kids

Actually, if you use the --mangle option with uglify, the code won't be exactly the same way it was even after beautification. Only hardcore pros would still be able to understand the code at that point.
Re: Need Step On How To Hide Javascript Source Code. by micodon(m): 8:57pm On Dec 02, 2016
chido4real:


Actually, if you use the --mangle option with uglify, the code won't be exactly the same way it was even after beautification. Only hardcore pros would still be able to understand the code at that point.

Like I said, "those who know what theyre doing" Wil know
Re: Need Step On How To Hide Javascript Source Code. by orimion(m): 10:41pm On Dec 02, 2016
chido4real:

Actually, if you use the --mangle option with uglify, the code won't be exactly the same way it was even after beautification. Only hardcore pros would still be able to understand the code at that point.
The thought of going through all these to hide JS client side means something is wrong. Like someone said, what ever needs to be hidden has to be done server side. People are making open source projects, someone wants to hide client side JavaScript

1 Like

Re: Need Step On How To Hide Javascript Source Code. by romme2u: 12:18am On Dec 03, 2016
orimion:

The thought of going through all these to hide JS client side means something is wrong. Like someone said, what ever needs to be hidden has to be done server side. People are making open source projects, someone wants to hide client side JavaScript

what shalln't i see

1 Like

Re: Need Step On How To Hide Javascript Source Code. by chido4real(m): 9:05am On Dec 03, 2016
Lol. For the record, I'm not in support of hiding JavaScript source code...
Re: Need Step On How To Hide Javascript Source Code. by GoodMuyis(m): 2:36pm On Dec 05, 2016
chido4real:
Lol. For the record, I'm not in support of hiding JavaScript source code...

am ready to do it, because of Intellectual theft,
Someone can steal your work and make money from it while you are yet to settle down
Re: Need Step On How To Hide Javascript Source Code. by Nobody: 1:31am On Dec 06, 2016
Oladg2:
Need step on how to hide javascript source code .

You 've been watching too much Hollywood films about hackers bro. Lol And I think you are afraid and trying to implement as much security as you can.grin grin grin grin grin

Relax Bro. Lol There is nothing to hide in your javascript source. It's not necessary.

I think you should be more concerned with correct configuration for your server side environment. Ok. That's a where a nice and terrible attack will target.
Re: Need Step On How To Hide Javascript Source Code. by haleighaugustu: 9:59am On Jun 09, 2022
It also introduced four new biomes, as well as various structures. As time progressed, the game's boundary became more unstable. Eventually, chunks beyond 30 million blocks could not be rendered, and the game crashed in an illegal position. You are curious to know more about minecraft survival servers, go here.
Re: Need Step On How To Hide Javascript Source Code. by Nobody: 12:26pm On Jun 09, 2022
Oladg2:
Need step on how to hide javascript source code .
Ask GREATIGBOMAN he should know since he knows everything

(1) (Reply)

"oracle",is It Losing It's Demand In Today's Nigerian Labor Market? / Free Ebooks On Php Progaming / Programmers Are Good In Mathematics

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 30
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.