I see there is a way to programming javascripts in one lines,
i need to way what have i take a look before make it one lines ?
please someone suggest me,
thanks,
I don't wuite understand what you mean, but if you mean to program javascript in one line that is perfectly possible. all you need to do is not use the tab or enter button at all. As long as everything is syntacticaly correct it will work.
Still, it is really hard to read such JavaScript, so I recommend programming it normally and later compressing it.
You just program your javascript normally, making sure to end every line with a semi-colon. (Where a semi-colon is appropriate.)
Next, you have two options:
Press end, delete, end, delete, end, delete untill all your code is on 1 line.
Do a regular expression delete (eg. replace by nothing) for [\r\n]* (or [\r\n\t]*)
as i assume.. i think u wanna do some obfuscation in ur js.
i created a long2x and big javascript about 38 Kb, i already compressed it with w3compiler, but it seem the script cannot be loaded because some error.*there is no error messages, i knowed it from my AJAX didn;t work.*
i already add semi colon every end of lines, and how about tag comment ?
/* */ <- need to add a semicolon also ??
| Philip wrote: |
i created a long2x and big javascript about 38 Kb, i already compressed it with w3compiler, but it seem the script cannot be loaded because some error.*there is no error messages, i knowed it from my AJAX didn;t work.*
i already add semi colon every end of lines, and how about tag comment ?
/* */ <- need to add a semicolon also ?? |
You don't have to put a semicolon on every line, only where appropriate.
And make sure you don't use this style of comments:
| Code: |
Code 1
// Comment
Code 2 |
As that will result in:
| Code: |
| Code 1 // Comment Code 2 |
So the Code 2 will also be commented out
i still dont get, still had the error after compress the javascript files,
how about if syntax ?
is it right syntax ?
| Code: |
if(a==b)
{
a=true;
}
else
{
a=false;
} |
| Philip wrote: |
i still dont get, still had the error after compress the javascript files,
how about if syntax ?
is it right syntax ?
| Code: | if(a==b)
{
a=true;
}
else
{
a=false;
} |
|
Yes it is.
If you compress it to:
| Code: |
| if(a==b){a=true;}else{a=false;} |
it will work
how about using ' and " tag for containing string for variable ?
I dont quite get what your saying but if your trying to make it neater and your code shorter have you considered using an external javascript file.
[url]<script type="text/javascript" src="externalfiles/js/1formcheck.js"></script>[/url]
that would load an external javascript file one thing though do not add the
[url]<script></script>[/url] tags to the file or itll screw up[/url]