Multiple loops

F

Fabian Vilers

Hi all,

I'm my script I've three loops processing a very huge data file. IE &
Firefox show a message box after some time saying my script could be
infinite looping and give me a chance to stop it.

Is there a way to prevent this dialog box to show up? I'm writing a
script used only on a intranet and the final customer should not see the
message box.

Thanks in advance,
 
E

Evertjan.

Fabian Vilers wrote on 06 feb 2006 in comp.lang.javascript:
I'm my script I've three loops processing a very huge data file. IE &
Firefox show a message box after some time saying my script could be
infinite looping and give me a chance to stop it.

Is there a way to prevent this dialog box to show up? I'm writing a
script used only on a intranet and the final customer should not see the
message box.

Consider not using clientside scripting.
 
E

Evertjan.

Fabian Vilers wrote on 06 feb 2006 in comp.lang.javascript:
Unfortunately, this is not an option.

A programmer without technically necessary options
should decline the assignment!

In-browser javascript is not fitted for huge tasks.
[due to time and memory constraints]

Try:

A good database, w/cscript, compiled tasks like VB, c++, etc.
 
F

Fabian Vilers

Evertjan. said:
A programmer without technically necessary options
should decline the assignment!

In-browser javascript is not fitted for huge tasks.
[due to time and memory constraints]

Try:

A good database, w/cscript, compiled tasks like VB, c++, etc.

Thanks for your analysis Evertjan ;-) Like I said, I've no option. My
best choice for now on is to make big replace in a string :( (see other
post).

Thanks anyway
 
T

Thomas 'PointedEars' Lahn

Fabian said:
I'm my script I've three loops processing a very huge data file. IE &
Firefox show a message box after some time saying my script could be
infinite looping and give me a chance to stop it.

Is there a way to prevent this dialog box to show up? I'm writing a
script used only on a intranet and the final customer should not see
the message box.

Since as you say not only using client-side scripting is not an option, I
think with unchanged code (see below) you will have to restrict your target
browser to Firefox and have your clients set this preference in their
user.js configuration file (or via `about:config'):

user_pref("dom.max_script_run_time", "0");

Setting this preference to 0 is specified to disable the warning. I have
set it to 60 (seconds) here.

I do not know if there is such a preference for IE, hence the Firefox
restriction.

However, you should definitely analyze the efficiency of your code,
especially of your loops, before you try anything else. For example,
using

/* a is an Array or collection object */
// order does not matter
for (var i = a.length; i--;)

or

// order does matter
for (var i = 0, len = a.length; i < len; i++)

is known to be faster than

for (var i = 0; i < a.length; i++)

Storing references of lookups from to the second level upwards in a (local)
variable and reusing that variable instead of looking up over and over
again (as was done in the first two examples) is another working means to
increase runtime efficiency, thus decreasing runtime.


HTH

PointedEars
 
T

Thomas 'PointedEars' Lahn

Thomas said:
Fabian said:
["script too slow" warning in IE and Firefox]

Since as you say not only using client-side scripting is not an option, I
think with unchanged code (see below) you will have to restrict your
target browser to Firefox and have your clients set this preference in
their user.js configuration file (or via `about:config'):

user_pref("dom.max_script_run_time", "0");

Should be

user_pref("dom.max_script_run_time", 0);

of course.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top