473,848 Members | 1,548 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 3621
tg****@gmail.co m 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.co m 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.co m 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.javas cript 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.co m 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.co m 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
3022
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 muddled and cumbersome. I need to be able to build any version of the database from scratch, BUT I also need to maintain an upgrade path from any version to any later version. So it is not enough to just maintain a master build script, but I...
11
9294
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 C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
136
9492
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
0
1880
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 and integrate them into our application. I will be managing the identification and loading of these plugins. In addition, there are a number of assemblies that plugins will reference, some shared, and others private. There are a couple of...
10
3490
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 somewhere that each folder under the "web site" is compiled in separate assembly. I however, did not find that the "web site" creation in vs.net 2005 created any AssemblyInfo.cs file.
4
2993
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 necessitate significant customization of any off-the-shelf application. In the end, we decided it would be more feasible to build one to our specifications. What I am looking for are a list of best practices/recommendations for the architecture...
3
1217
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 which users have access to various reports. The page will display the report name and a list of users who currently have access. The administrator will be able to add or delete from this list of users, then save the results to the database....
9
1797
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 and backdoors that could provide hours of pleasant diversion writing obfuscated code. Don't write like that on the job. Always write similar, obvious statements to do similar, simple things. Engineers learn their working vocabulary from...
1
1424
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. So... Best practises, in good object oriented fashion: how do I do it. I'm thinking making classes for data access. An Example that ALL books do - customer - and orders. So I'm thinking: Making a customer class
0
9735
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10997
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10661
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9497
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7067
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5731
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4542
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 we have to send another system
3
3172
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.