/    Sign up×
Community /Pin to ProfileBookmark

I need loading spped how can the number of lines be reduced

I know this will process slow, but i need to somehow reduce teh number of lines of code… can you help?

function CalcIt ()
{
with (document.f8)
{
for(var n = 0; n < ad1.length; n++)
{
var val1 = (ad1[n].checked) ? parseInt(document.f8.ad1[n].value) : 0 ;
if (val1 != 0) break;
}

var ilt = val1
+ (ad2.checked ? parseInt(ad2.value) : 0)
+ (ad2.checked ? parseInt(ad3.value) : 0)
+ (ad2.checked ? parseInt(ad4.value) : 0)
ilt = ilt > 17 ? 17 : ilt ;

}
}

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JonaApr 25.2003 — Removing lines won't decrease loading time... Mainly images would be the problem.
Copy linkTweet thisAlerts:
@catchupauthorApr 25.2003 — thanks for the knowledge.

Can you reduce the number of lines of code?
Copy linkTweet thisAlerts:
@JonaApr 25.2003 — Yup...

function CalcIt(){with(document.f8){for(var n = 0; n < ad1.length; n++){var val1 = (ad1[n].checked) ? parseInt(document.f8.ad1[n].value) : 0 ;if(val1!=0)break; }var ilt=val1+(ad2.checked ? parseInt(ad2.value) : 0)+(ad2.checked ? parseInt(ad3.value) : 0)+(ad2.checked ? parseInt(ad4.value) : 0)ilt = ilt > 17 ? 17 : ilt;} }
Copy linkTweet thisAlerts:
@VladdyApr 25.2003 — Here is an ASP script I came up with awhile ago. Used to publish *.js scripts on your server, stripping off all the comments and extra spaces (make sure you do not miss any semicolons). Depending on your coding habbits the size can be reduced by a factor of two or so. Also you give some extra headache to those stealing your work ? .
[CODE][size=1]
<%@ Language =JScript EnableSessionState = False%>
<%
Response.Buffer = true;
Response.Expires = 0;
%>
<!--#include file="FileUpload.asp"-->
<html>
<head>
<title>Publish JavaScript</title>
</head>
<body>
<%
scriptsFolder = 'ClientScripts/';

if(Request.QueryString('Submit')=='True')
{ fileName = fileFields(0,2);
pFN=/.*\(.*)/;
fileName = fileName.replace(pFN,"$1");
if(fileName.length > 0)
{ code = fileFields(0,1);
%>
<h3>Publishing file: <%Response.Write(fileName);%> </h3>
<p>Orginal Code: (size: <%Response.Write(0.001*code.length);%> KB)</p>
<% pStartComment = //*/;
pEndComment = /*//;
pSLComment = ///[^n]*/g;
pExtraSpace = /s+/g;
pSpace = /s?([{};=()\/+*-])s?/g;
pieces = code.split(pStartComment);
code = '';
for(i=0; i<pieces.length;i++)
{ code += pieces[i].split(pEndComment)[1];
}
code = code.replace(pSLComment,'');
code = code.replace(pExtraSpace,' ');
code = code.replace(pSpace,'$1');
savePath = Server.MapPath(scriptsFolder + fileName);
var fso = Server.CreateObject("Scripting.FileSystemObject");
var scriptFile = fso.CreateTextFile(savePath, true);
scriptFile.Write(code);
scriptFile.Close();
%>
<p>Published file: (size: <%Response.Write(0.001*code.length);%> KB)</p>
<%
}
else
{
%>
<h3>File not found</h3>
<%
}
}
else
{
%>
<form action="PublishJS.asp?Submit=True" method="post" enctype="multipart/form-data">
<input type="file" name="File" value="" style="width:100%;" />
<input type="submit" name="Submit" value="Submit" />
</form>
<%
}
%>
</body>
</html>
[/size]
[/CODE]


FileUpload.asp is attached with *.txt extension

[upl-file uuid=bdde7ee3-3cbd-4cc6-af11-c98440dde774 size=2kB]fileupload.asp.txt[/upl-file]
×

Success!

Help @catchup spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...