I
Ian Richardson
I'm writing a large Javascript application (uncompressed source around
400K) which is doing almost all the initialisation it needs to in a
just-in-time manner. However, I have included an option for almost all
of this to be done when the application first starts.
Under this circumstance, and since the last few nightly builds of
Mozilla, I've been getting:
Script warning:
A script on this page is causing mozilla to run slowly. If it continues
to run, your computer may become unresponsive.
Do you want to abort the script?
I think this is being displayed because of the time it's taking to start
up rather than the amount of code it's wading through, but it's as good
an excuse as any to look at optimizing code. [I've just realised and
fixed one processor-intensive chunk of code which was being processed
six times during startup; fine except the first four (possibly five,
depending on circumstances) were completely unnecessary!]
What I need is:
1. A means of being able to forcibly skip this message
2. A faster form of loop than for(x in list)
3. A faster sort than a quicksort for a SELECT list
4. A faster form of search - I'm currently using binary search
5. A fast way of getting one OPTION at any point in a SELECT list moved
to the top of the list. I'm currently using a method akin to a bubble sort.
[Lists can be up to 1000 items...]
I know I might be asking for the moon on a stick, but any help would be
greatly appreciated.
Thanks,
Ian
400K) which is doing almost all the initialisation it needs to in a
just-in-time manner. However, I have included an option for almost all
of this to be done when the application first starts.
Under this circumstance, and since the last few nightly builds of
Mozilla, I've been getting:
Script warning:
A script on this page is causing mozilla to run slowly. If it continues
to run, your computer may become unresponsive.
Do you want to abort the script?
I think this is being displayed because of the time it's taking to start
up rather than the amount of code it's wading through, but it's as good
an excuse as any to look at optimizing code. [I've just realised and
fixed one processor-intensive chunk of code which was being processed
six times during startup; fine except the first four (possibly five,
depending on circumstances) were completely unnecessary!]
What I need is:
1. A means of being able to forcibly skip this message
2. A faster form of loop than for(x in list)
3. A faster sort than a quicksort for a SELECT list
4. A faster form of search - I'm currently using binary search
5. A fast way of getting one OPTION at any point in a SELECT list moved
to the top of the list. I'm currently using a method akin to a bubble sort.
[Lists can be up to 1000 items...]
I know I might be asking for the moon on a stick, but any help would be
greatly appreciated.
Thanks,
Ian