473,506 Members | 17,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

best practices managing js obfuscated code?

I would be interested to hear how others are managing their javascript
(.js) files from the original code vs the obfuscated version they
publish to their site/webapp.

I currently manage 2 files, and everytime i need to make a change, I
have to switch the names, test, then rename again, obfuscate to the
original file name (because this is the file referenced in php/perl/asp
whatever files). So its kind of a pain.

Any thoughts out there? Be very interested to hear how you are
managing your files.

Thx,
John

Nov 2 '05 #1
7 3605
tg****@gmail.com wrote:
I would be interested to hear how others are managing their javascript
(.js) files from the original code vs the obfuscated version they
publish to their site/webapp.


I do not obfuscate my code; as mentioned here before, it would be a
Bad Thing, e.g. because nobody could learn from it and easily reuse
it then. My local code (i.e. that is running on my local test server)
differs from public code in the respect that all JSdoc[tm] comments
have been removed from it. I currently make the commented versions
available in versioned subdirectories and short comments on top of
the "used" resources mention that. Maybe I will compact the "used"
code some time to save bandwidth and gain speed[1], but nothing more.
HTH

PointedEars
___________
[1] which is a two-edged sword: compacting code could introduce the
need for more statement delimiters than needed in uncompacted
code. I have yet to investigate that further.
Nov 2 '05 #2
Lee
tg****@gmail.com said:

I would be interested to hear how others are managing their javascript
(.js) files from the original code vs the obfuscated version they
publish to their site/webapp.

I currently manage 2 files, and everytime i need to make a change, I
have to switch the names, test, then rename again, obfuscate to the
original file name (because this is the file referenced in php/perl/asp
whatever files). So its kind of a pain.

Any thoughts out there? Be very interested to hear how you are
managing your files.


Sorry, but you're the only one who feels that hiding their code
is worth the effort.

Nov 2 '05 #3
tg****@gmail.com said the following on 11/2/2005 5:38 PM:
I would be interested to hear how others are managing their javascript
(.js) files from the original code vs the obfuscated version they
publish to their site/webapp.
The only people who obfuscate code are the ones who lack the
understanding to realize it is a waste of time. Not only from the
obfuscating point of view, but, from the maintenance point of view that
you are experiencing.

I have not seen your code but I promise you. Nothing you have done is so
unique that it has not been done, or will be repeated, in the past or
future.
I currently manage 2 files, and everytime i need to make a change, I
have to switch the names, test, then rename again, obfuscate to the
original file name (because this is the file referenced in php/perl/asp
whatever files). So its kind of a pain.
Precisely why you *shouldnt* obfuscate code. Its a waste of time.
Any thoughts out there? Be very interested to hear how you are
managing your files.


I manage them by using one file. I edit it, I publish it, no problems.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 3 '05 #4
I didnt necessarily mean obfuscate, but perhaps compress (i.e. remove
comments, remove tabs, white space, etc....), this often saves 30%+ of
file size - which can make a big difference.

Just curious how people are managing their files.

Nov 3 '05 #5
VK

tg****@gmail.com wrote:
I didnt necessarily mean obfuscate, but perhaps compress (i.e. remove
comments, remove tabs, white space, etc....), this often saves 30%+ of
file size - which can make a big difference.


Then it's called "script squeezer" (old term) or "script compactor"
(newer term) and it's indeed a great tool for delivering big scripts to
the client-side (up to 70% compression).

Nov 3 '05 #6
tg****@gmail.com wrote:
I would be interested to hear how others are managing their javascript
(.js) files from the original code vs the obfuscated version they
publish to their site/webapp.

I currently manage 2 files, and everytime i need to make a change, I
have to switch the names, test, then rename again, obfuscate to the
original file name (because this is the file referenced in php/perl/asp
whatever files). So its kind of a pain.

Any thoughts out there? Be very interested to hear how you are
managing your files.

Thx,
John


I don't necessarily think of what I do with my code as obfuscation as
much as compression, but for the scripts at
http://www.unfocus.com/projects/FlashSuite/ - I develop using a folder
structure (that I got from an actionscript book - though I've seen it
elsewhere too) - I have a source folder, and a deploy folder (and some
others like an assets folder).

In the source folder I have all of the uncompressed javascript files
(and actionscript files, flas/swfs, etc.) commented all over (am in the
process of switching to JSDoc style comments), with each class in it's
own file, arranged in a namespace like directory structure.

In the deploy folder I have my html files (if I'm using the js classes
for a site) and the rest of the site folders (images folder scripts
folder, etc.). In the scripts folder, I have at least two files, one
that contains every js class that I intend to use for the site, just
copied in from the individual js class files (I usually call it
unFocusLib.js) and another js file with a -p on the end of the name
(like unFocusLib-p.js) which is just the large file compressed with Dean
Edward's packer tool (http://dean.edwards.name/packer/).

Active development on the js classes usually takes place in an html file
in the source folder, that links to all the individual class files. Then
the working code is just copied to the deploy folder, where the window
dressing is usually applied.

I'm not sure this is the best way, but it is the way I do it for now. :-)

Kevin N.

P.S. I include a link in the compressed files to where you can get the
source code. There's no reason to hide anything.

P.P.S. I haven't released an updated package yet that reflects what I
described here, and am still refining that work process and directory
structure. ;-P
Nov 3 '05 #7
> I didnt necessarily mean obfuscate, but perhaps compress (i.e. remove
comments, remove tabs, white space, etc....), this often saves 30%+ of
file size - which can make a big difference.

Just curious how people are managing their files.


I use JSMin to minify my JavaScript files.
http://www.crockford.com/javascript/jsmin.html
Nov 4 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2993
by: Woody | last post by:
I am looking for some examples of how to manage DDL scripts among various versions of a production db and development and testing. I have tried a few things in the past, and it always gets very...
11
9212
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
136
9201
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
0
1854
by: David Levine | last post by:
This is a lengthy post; please bear with me... This will be a large system with dozens of plugins. In addition to plugins developed internally there will be 3rd parties that will write their own...
10
3416
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
4
2954
by: DeepDiver | last post by:
I am developing an inventory database in SQL Server. I realize there are many commercial (as well as some non-commercial) inventory offerings, but my client has specific requirements that would...
3
1205
by: Jim Underwood | last post by:
I am not sure if web server control templates are the way to go or not, but I would like to get some opinions on the best way to go about this. I have a web page where administrators will specify...
9
1776
by: Phlip | last post by:
Newsgroupies: Good guidelines keep source code within a "comfort zone". Programming languages provide extraordinarily wide design spaces, much wider than hardware designs enjoy, with many tricks...
1
1361
by: DelphiLover | last post by:
Hi. I'm reading and reading, testing and testing, trying to figure out how to do things, how to do things according to best practises and how to do things in the best object oriented way. ...
0
7220
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.