Jump to content


Photo

Should I obfuscate my JavaScript?

javascript obfuscate obfuscated javascript obfuscate javascript

  • Please log in to reply
5 replies to this topic

#1 Eox

Eox

    Member

  • Members
  • PipPip
  • 22 posts

Posted 01 January 2013 - 01:42 PM

Hello!

 

I have a project where I work a lot with JavaScript on the UI. I saw that Google and all other big sites obfuscate there javascript.

 

This code

function showMessage( message )
{
    alert(message);
}

showMessage('Hello!');

 

will be after the obfuscation this code

function a(b){alert(b);}a('Hello!');

 

 

Should I obfuscate my JavaScript too? And what are the reasons to do that? Security, Performance or both?

And when I should obfuscate my JavaScript how I do it right?

 

 

Thanks!

 

Eox

 

 

PS: Sorry for my skills in english :D



#2 ancit

ancit

    Member

  • Members
  • PipPip
  • 10 posts

Posted 01 January 2013 - 02:41 PM

Perhaps you mean increase Page Load Speed by Compressing Files CSS & JavaScript.

 

For more information you can enter to below link.

http://jscompress.com/

:)



#3 Eox

Eox

    Member

  • Members
  • PipPip
  • 22 posts

Posted 01 January 2013 - 04:02 PM

Perhaps you mean increase Page Load Speed by Compressing Files CSS & JavaScript.

 

For more information you can enter to below link.

http://jscompress.com/

:)

 

Thanks  :)

 

And they compress their JavaScript only for increase Page Load Speed or is there also a security improvement? 



#4 ancit

ancit

    Member

  • Members
  • PipPip
  • 10 posts

Posted 01 January 2013 - 05:26 PM

I think security issue not related to compress files.



#5 jream

jream

    Administrator

  • Administrators
  • 52 posts

Posted 01 January 2013 - 08:38 PM

Obfuscation will decrease load times, but at the cost of microseconds probably.. What some do is compress all JS files into one and obfuscate it so it only uses one HTTP request for the javascript. Google does it because they get millions, probably billions of visits a day.

 

I would be careful doing this, here is why.

 

1. I think a lot of people think too early about "scaling", it seems like a trendy word. I'd say 99% of applications developed never need to be scaled, they usually never get big enough to need to do this. Rather than spend time worrying about scaling I would focus on building the app and getting it popular, if and when the time comes it became very popular, then scaling procedures like this should come into play

 

2. You may lose your original code, and you dont want to try and fix that!

 

3. Its a pain in the butt to make updates!

 

At the end of the day you have to decide if its worth it. To me, a few microseconds doesn't matter if it's even that.



#6 Eox

Eox

    Member

  • Members
  • PipPip
  • 22 posts

Posted 01 January 2013 - 11:01 PM

Yes, thats right. 

 

I thought it could improve the secruity of my application when my javascript is harder to read. And I would look for a PHP class which would obfuscate my javascript files. So I would update my javascript and on my PHP skript would detect this and obfuscate this new code and saves it in a cache. 

 

 

But I dont need it when it is only for performance. My site loads really fast and some day when it takes longer time to load my website I would look for things which improve the load time.

 

 

Thank you! I think I will think about it again when my site has millions of views each month :D







Also tagged with one or more of these keywords: javascript, obfuscate, obfuscated javascript, obfuscate javascript

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users