Is it possible to obfuscate an Angular project's source code? - javascript

I have an Angular project and I would like to know if it's possible to obfuscate the code that rendered the browser, so others cannot copy it.
The Web Project is Angular + TS
And I Would like know if it's possible obfuscate the JS Code that I can view in the browser console

No it is not possible. The browser needs to understand what you have wrote.
As you already said, the only option is obfuscation, it doesn't make your code safe just harder to read.

Related

How to deminify next.js html from internet

I'm trying to rebuild a website that I scraped from the web using wget. It appears to be a next js application, as I see the _next folder. I have 0 experience in nextjs and have no idea what the inner workings are, but it seems like it is somehow minifying all the code into a single script.
Is there any way to "undo" this and make it look like pretty HTML?
Here is what it looks like
Unfortunately this isn't possible, as the HTML you scraped is pre-rendered static HTML by NextJS that's later hydrated by the JavaScript, which resides in the chunks folder.
To recreate the website, you'll first have to recreate all the JavaScript that was transpiled into chunks by WebPack or SWC, which is no easy task. It's laborious and can only be minimally automated, and there's no way to "demangle" code that's been transpiled back into its original form.
There might be a better solution to your question if you provide more information about your target and motivation behind doing so. Otherwise, I'd strongly recommend not spending time trying to reverse transpiled code.

Prevent functions from showing up in source - Angular

This is a general question.
Normally any code we write in Angular is compiled into a bundle file which is served to the browser right?! This JavaScript code which we write is visible as it is in the bundle file while viewing source. How do we prevent our code from being propagated. Is there any Obfuscator that works in real time for protecting our algorithms?
Try plugins to suit your needs. Modern angular versions come with webpack which can do minification and mangling. There are limitations to JavaScript obfuscation especially for angular code which needs certain keywords to work that cannot be changed. If you need to hide code consider moving it to server. All JavaScript client code should be considered vulnerable to being read.

Difficult to read source code for some web pages?

I have been trying to find an explanation for this, but everywhere I looked doesn't seem to answer my question. Essentially, whenever I look at the "view page source" option on a webpage like Facebook or my school's home page (gvsu.edu), the source code is just a huge wall of text. As a result, I have a few questions:
Is this how it looks in the editor? If not, why is it formatted this way when I look at the source code?
Is there any way to decipher this code so I can see how it works?
Are there any advantages to formatting the code this way?
Thanks.
Is this how it looks in the editor? If not, why is it formatted this way when I look at the source code?
no, usually programmers try to make code as readable as they can, this is a "minified" version of the code, it's done to make files smaller so people can receive it faster in their browsers.
Is there any way to decipher this code so I can see how it works?
you can use some online tool to like this, you will have to format html, css and javascript individually.
Are there any advantages to formatting the code this way?
already answered, but here I can add that usually you don't format the html/css/js that way, you have a tool that does that job for you like gulp-htmlmin, gulp uglify, cssmin or many others, and you work with a "development" version of the files, when you are done editing you run some scripts and they spit that minified version to you, so you can upload it to your server.

How to inject javascript on tomcat server without changing jsp/html file

is there a way to inject javascript into pages served by tomcat?
I know it can be performed by http://httpd.apache.org/ but not sure about tomcat.
Reason: I do not wish to edit the deployment by project team to perform instrumentation, they might blame me for code change, but if I can inject without change to their code It will insulate myself from being blamed =x
Please provide reason when voting my question so I can improve.
If you don't care about persistent code, I think the fastest way to inject code is to open up the developer tools and copy&paste the javascript code you need to inject.
In chrome you can edit the source code and when you "save" the changes it will recompile all the javascript code.
Other browsers should have this "feature" as well.
Keep in mind that if you leave/close/refresh the page all the code you have injected will be lost.
Hope this helps

Performance on phonegap

Resently I have created an PhoneGap app.
Now I want to make more Efficient as it is very slow.
So I am searching on google & SO that minify version is make more faster then regualar .js file
also according tho this.
css best practices - combining all css into a single stylesheet?
keeping everything on file is good thing from fatching file from server but as in Phonegap app everything is at client side.
now my Questions are
1) does minify improves notable performance?
2) is it good Practice to make diffenet .js file or put everything on same is good one?
For your two questions my answer is quite similar.
2) Yes is always a good practice to write javascript in a different file as when you include that the file in you page almost every browser provides you the caching.
For the first time broswer looks into the cache and download the .js file from the server and store in its cache.
When again the same file is included it wil not download the js file but will refer to the cache.
This surely improves the performance.
1) As I explained above for the first time evrey js file gets download to client side. Now if you minify the js the download size will be very less hence will improve you performance. But it doesnt mean that you javascript code will start performing faster when you minify the js file.
Both the cases will improve the performance in some manner.
yeah you are right that why one should create a minify verstion of script if everything is going to run on client side , but in my experience there are two main benifits :
-One is while creating minify version , the compiler guides you about best practices and creates warning where required ( sencha cmd does).
-Other point is your app does reduce in size.
-You can have clean production version of your app.
Thanks
Here's some alternative approach to it.
Basically minifying and deferred loading of JavaScript files is a good practice. However, you can also consider trying native UI widgets on your apps to render the page much faster.
I am using Monaca for a while and found its native component very efficient and high performance. It's open-source as well. Take a look at the API reference.
The alternative solution is to use Steroids. It is closed-source, but it provides similar functions and components.

Categories

Resources