By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,181 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,181 IT Pros & Developers. It's quick & easy.

Netscape 7.02 - script problem.

P: n/a
Netscape 7.02 is giving me a headache with a downloaded snow script.
Starting with a blank page, I inserted the script and checked it in IE
6 and Netscape 7.02. Everything worked and looked fine. A check on CPU
usage (Windows Task Manager>Performance) gave a 0% to 2% reading for
both browsers on a Pentium 4, 3.06GHz running XP.

As I added text, images, tiled background and so on. I noticed the
mouse was becoming jerky in Netscape 7. Another CPU usage check now
gave a 98% peak reading for N7 but still 2% in IE??

I removed the tiled background jpg, which brought it down to 33%. Then
removed the text and images, now a blank page again except for the
script, which returned it to 0% to 2%!

Is there a problem with this script or is it down to Netscape 7? I've
used loads of animation scripts before in trusty old Netscape 4 and
never had any problems like this - I've not long upgraded to 7.

Anyway, the script I'm using is from
http://www.btinternet.com/~kurt.grig...t/SnowImg.html
Is it duff and if so where can I find another? The page is for my
9-year-old daughter, she really wants a snow theme and Daddies looking
a bit dim at the moment.

Thanks for any help,
Jonny.
Jul 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
although this is a rather poorly programmed script, Netscape is to blame.

I have only looked at it in MSIE 6 and Mozilla Firebird 0.7, and experianced
similar issues, it seems that MSIE has a much cleaner way of drawing the
webpages, which means that when something is being drawn over and over it
slows the computer down much more.

Here is the easiest solution I can come up with:
change this line:
runspeed=40; //setTimeout speed!

to something like this:
runspeed=navigator.appName == "Microsoft Internet Explorer"?40:500;
//setTimeout speed!

This is not a great solution as it makes the snow jumpy on non MSIE
browsers, but it will save your CPU and stop the mouse jumping

"Jonny" <jo**********@yahoo.co.uk> wrote in message
news:f4**************************@posting.google.c om...
Netscape 7.02 is giving me a headache with a downloaded snow script.
Starting with a blank page, I inserted the script and checked it in IE
6 and Netscape 7.02. Everything worked and looked fine. A check on CPU
usage (Windows Task Manager>Performance) gave a 0% to 2% reading for
both browsers on a Pentium 4, 3.06GHz running XP.

As I added text, images, tiled background and so on. I noticed the
mouse was becoming jerky in Netscape 7. Another CPU usage check now
gave a 98% peak reading for N7 but still 2% in IE??

I removed the tiled background jpg, which brought it down to 33%. Then
removed the text and images, now a blank page again except for the
script, which returned it to 0% to 2%!

Is there a problem with this script or is it down to Netscape 7? I've
used loads of animation scripts before in trusty old Netscape 4 and
never had any problems like this - I've not long upgraded to 7.

Anyway, the script I'm using is from
http://www.btinternet.com/~kurt.grig...t/SnowImg.html
Is it duff and if so where can I find another? The page is for my
9-year-old daughter, she really wants a snow theme and Daddies looking
a bit dim at the moment.

Thanks for any help,
Jonny.

Jul 20 '05 #2

P: n/a
"neerolyte" <ne*******@netspace.nOsPaM.net.au> wrote in message news:<bt**********@otis.netspace.net.au>...
although this is a rather poorly programmed script, Netscape is to blame.

I have only looked at it in MSIE 6 and Mozilla Firebird 0.7, and experianced
similar issues, it seems that MSIE has a much cleaner way of drawing the
webpages, which means that when something is being drawn over and over it
slows the computer down much more.

Here is the easiest solution I can come up with:
change this line:
runspeed=40; //setTimeout speed!

to something like this:
runspeed=navigator.appName == "Microsoft Internet Explorer"?40:500;
//setTimeout speed!

This is not a great solution as it makes the snow jumpy on non MSIE
browsers, but it will save your CPU and stop the mouse jumping


For any animated script, the timeout/interval has to be at least 50ms.
Any lower and it just is NOT animated. Netscape 4 handled this sort of
script with ease as IE continues to.

Whether the new Netscape's & Opera's are or nor "technically correct"
in their redrawing is beside the point. They are alienating lots of
people who like this sort of script and helping IE towards total
domination.

As for the script in question, It has an option to hide itself from
Netscape 7; I'd just use that and forget about it. You can try
http://www.dynamicdrive.com for something else.
Jul 20 '05 #3

P: n/a
DU
neerolyte wrote:
although this is a rather poorly programmed script, Netscape is to blame.

In part, this is true. Mozilla-based browsers are struggling with very
demanding animation DHMTL scripts. This is exactly the case here:

Bug 64516: 95-99% CPU usage for dhtml "snow effect"
http://bugzilla.mozilla.org/show_bug.cgi?id=64516

Bug 186442: "snowfall" script causes browser to slow to a crawl
http://bugzilla.mozilla.org/show_bug.cgi?id=186442
I have only looked at it in MSIE 6 and Mozilla Firebird 0.7, and experianced
similar issues, it seems that MSIE has a much cleaner way of drawing the
webpages, which means that when something is being drawn over and over it
slows the computer down much more.

Yep!
Here is the easiest solution I can come up with:
change this line:
runspeed=40; //setTimeout speed!

to something like this:
runspeed=navigator.appName == "Microsoft Internet Explorer"?40:500;
This is not the best way to detect browsers. Anyway, I think the main
issue is the setTimeout value. I still don't recommend anything under
64msec or even 128msec for such page. The original poster has a 3Ghz
cpu: that,s not the case for many users.
//setTimeout speed!

Correct again! There are a lot of badly coded scripts out there in
Cut-N-Paste javascript sites which mindlessly have scripts resorting to
insane setTimeout values demanding insane cpu, video and memory resources.


This is not a great solution as it makes the snow jumpy on non MSIE
browsers, but it will save your CPU and stop the mouse jumping

It is a better solution than you may think. setTimeout values (in
particular in recursive calls and intense DHTML animations) should never
be faster than 64 msec. for demanding scripts. Even MSDN says so too.

"Code optimization:
setTimeout
Speaking of animation, one of the most common techniques for animating
elements is to use a timer with window.setTimeout to position an element
on the page incrementally. A quick tip: Use as few timers as possible.
Timers consume valuable system resources, and the behavior of multiple
timers, all working together, will greatly vary on differently powered
machines. A way to animate multiple elements, while minimizing timer
use, is to employ a single main loop, powered with a single
window.setTimeout() call. In that single loop, keep a list of all
elements you need to manipulate. Loop through that list with each tick,
and perform your required move."
Michael Wallent
Microsoft Corporation
http://msdn.microsoft.com/library/de...l/dude1201.asp

DU

"Jonny" <jo**********@yahoo.co.uk> wrote in message
news:f4**************************@posting.google.c om...
Netscape 7.02 is giving me a headache with a downloaded snow script.
Starting with a blank page, I inserted the script and checked it in IE
6 and Netscape 7.02. Everything worked and looked fine. A check on CPU
usage (Windows Task Manager>Performance) gave a 0% to 2% reading for
both browsers on a Pentium 4, 3.06GHz running XP.

As I added text, images, tiled background and so on. I noticed the
mouse was becoming jerky in Netscape 7. Another CPU usage check now
gave a 98% peak reading for N7 but still 2% in IE??

I removed the tiled background jpg, which brought it down to 33%. Then
removed the text and images, now a blank page again except for the
script, which returned it to 0% to 2%!

Is there a problem with this script or is it down to Netscape 7? I've
used loads of animation scripts before in trusty old Netscape 4 and
never had any problems like this - I've not long upgraded to 7.

Anyway, the script I'm using is from
http://www.btinternet.com/~kurt.grig...t/SnowImg.html
Is it duff and if so where can I find another? The page is for my
9-year-old daughter, she really wants a snow theme and Daddies looking
a bit dim at the moment.

Thanks for any help,
Jonny.


Jul 20 '05 #4

P: n/a
Lee
Mike said:
Whether the new Netscape's & Opera's are or nor "technically correct"
in their redrawing is beside the point. They are alienating lots of
people who like this sort of script and helping IE towards total
domination.

As for the script in question, It has an option to hide itself from
Netscape 7; I'd just use that and forget about it. You can try
http://www.dynamicdrive.com for something else.


Apparently, no version of Netscape beyond 4 was available to the
author when he wrote the code. It treats it as an "other" browser,
and not very efficiently. Blaming the browser for having trouble
with bad code is one reason why IE is the predominant browser among
people who don't know any better.

Jul 20 '05 #5

P: n/a
Lee <RE**************@cox.net> wrote in message news:<bt*********@drn.newsguy.com>...
Apparently, no version of Netscape beyond 4 was available to the
author when he wrote the code. It treats it as an "other" browser,
and not very efficiently. Blaming the browser for having trouble
with bad code is one reason why IE is the predominant browser among
people who don't know any better.


The coding for the script isn't bad at all. The main repeating
function is very basic:

Increase y-pos at a random speed, give x-pos a bit of a wiggle.
When y-pos reaches the bottom of the page, reset y-pos, x-pos and
speed.
Assign y-pos, x-pos and speed to the objects[snow flakes] and repeat.
Simple.

Making it even more basic by removing the x-pos wiggle and the
scrolling doesn't affect the high cpu strain in N7, it's just as high.
The OP's tiled background problem is also true and a new one to me,
very odd and not acceptable.

I'm not for or anti any browser but N7 is not cutting the mustard with
dhtml.
Jul 20 '05 #6

P: n/a
DU
Mike wrote:
Lee <RE**************@cox.net> wrote in message news:<bt*********@drn.newsguy.com>...

Apparently, no version of Netscape beyond 4 was available to the
author when he wrote the code. It treats it as an "other" browser,
and not very efficiently. Blaming the browser for having trouble
with bad code is one reason why IE is the predominant browser among
people who don't know any better.

The coding for the script isn't bad at all. The main repeating
function is very basic:

Increase y-pos at a random speed, give x-pos a bit of a wiggle.
When y-pos reaches the bottom of the page, reset y-pos, x-pos and
speed.
Assign y-pos, x-pos and speed to the objects[snow flakes] and repeat.
Simple.


The algorithm as described is simple; the implementation in conformance
to W3C web standards is another issue and you want to support MSIE 6 for
windows when triggered in stdandards compliant rendering mode. The page
is far, very very far from such goal.
Making it even more basic by removing the x-pos wiggle and the
scrolling doesn't affect the high cpu strain in N7, it's just as high.
The OP's tiled background problem is also true and a new one to me,
very odd and not acceptable.

I'm not for or anti any browser but N7 is not cutting the mustard with
dhtml.

You first have to establish that the code is well written, robust,
compliant with widely established and acknowleged W3C web standards like
HTML 4.01, W3C DOM 2 events attributes and methods, W3C DOM Core
attributes and methods. Here, that page markup code does not even
validate, the browser detection is old, outdated and will often fail, it
resorts to document.write() calls in IE for no good reasons, it does not
use any DOM 2 events method, even the measurements of the viewport is
wrong for MSIE unless backward compatible rendering mode is used, etc..
For many reasons, professional web designers would judge that code as
not good at all.

Once and only once you have in front of you a well written code you can
assess (and compare with other browsers) the NS 7.x DHTML performance on
one single highly-resource-demanding animation script.

DU
Jul 20 '05 #7

P: n/a
Thanks all but I'm still having no luck with Netscape 7. I tried the
Snow Effect at
http://www.dynamicdrive.com/dynamicindex3/snow.htm
A slightly higher CPU reading than the first script and a full 100%
reading for Netscape 7 with a tiled background - I just don't get what
the background deal is about!

I also tried Snowmaker at
http://www.24fun.com/downloadcenter/snow/snow.html
The CPU reading was 30% for N7 (10 flakes) with a background, 0%
without. This one doesn't use images and isn't as pretty as the other
two.

Oh well, I'll stick with the first script and use its N7 hide feature.
It looks the best and I also like its timed clear out part.

Thanks again,
Jonny.
Jul 20 '05 #8

P: n/a
DU
Jonny wrote:
Thanks all but I'm still having no luck with Netscape 7. I tried the
Snow Effect at
http://www.dynamicdrive.com/dynamicindex3/snow.htm
A slightly higher CPU reading than the first script and a full 100%
reading for Netscape 7 with a tiled background - I just don't get what
the background deal is about!

I also tried Snowmaker at
http://www.24fun.com/downloadcenter/snow/snow.html
The CPU reading was 30% for N7 (10 flakes) with a background, 0%
without. This one doesn't use images and isn't as pretty as the other
two.

Oh well, I'll stick with the first script and use its N7 hide feature.
It looks the best and I also like its timed clear out part.

Thanks again,
Jonny.

You have not really understood all I wrote in my previous post. Here are
recommendations for you.

1- Make sure the page which will host this snow flakes falling randomly
uses valid, validated markup code. That means a correct and valid
doctype declaration, preferably a strict definition like HTML 4.01
strict along with a character encoding declaration:

W3C Quality Assurance tip
Don't forget to add a doctype:
http://www.w3.org/QA/Tips/Doctype

List of valid DTDs you can use in your document.
http://www.w3.org/QA/2002/04/valid-dtd-list.html

W3C validator:
http://validator.w3.org/

The Importance of Code Validation
http://www.wats.ca/articles/htmlvalidation/28

Why we won’t help you:
http://diveintomark.org/archives/200..._wont_help_you

Activating the Right Layout Mode Using the Doctype Declaration
http://www.hut.fi/u/hsivonen/doctype.html

2- Make sure you understand the javascript code and that you know for a
fact that it is optimized and that it will overwhelm users with modest
cpu/RAM/video resources. That means to limit the number of snow flakes
and recursive calls at set intervals. In other words, don't go with a
setTimeout(expr, 40)
but rather give preference to
setTimeout(expr, 128)
There are number of code optimization techniques available to make your
webpage code size, download time, parsing and rendering in browsers
small, fast, optimal. Same thing with optimization the CSS code and the
javascript code.

3- The %tage of cpu activity is just a sign, a symptom if you wish, of
the burden imposed onto the user's system resources by the script
functions. It is true that NS 7.1 and Mozilla-based browsers (compared
to MSIE 6 for windows for instance) is more sensitive to issues and
matters related to DHTML performance in animation scripts (and there is
a meta-bugfile at bugzilla on DHTML performance improvements) but IMO
this should not be a decisive factor. Good and optimized script
functions will be able to run on modest systems.
You gave %tage of cpu activity and you're using a 3Ghz cpu: consider the
ordinary visitor with a 500Mhz cpu to 1Ghz cpu.

In every single page, url you mentioned, none of them actually were
meeting the requirements I gave here.

Finally, consider that snow flakes effect are only cosmetic ornemental
graphical effects adding/bringing no content per se to a page but
demanding considerably quite a lot from the visitor's system; after a
while (a min or so), users get tired of it (it was established that
constantly running, moving graphics disturb and diminish peripherical
vision and concentration to read) and wish they could turn it off...only
to realize that they can't!

DU
Jul 20 '05 #9

P: n/a
DU <dr*******@hotREMOVETHISmail.com> wrote in message news:<bt**********@news.eusc.inter.net>...
You first have to establish that the code is well written, robust,
compliant with widely established and acknowleged W3C web standards like
HTML 4.01, W3C DOM 2 events attributes and methods, W3C DOM Core
attributes and methods. Here, that page markup code does not even
validate, the browser detection is old, outdated and will often fail, it
resorts to document.write() calls in IE for no good reasons, it does not
use any DOM 2 events method, even the measurements of the viewport is
wrong for MSIE unless backward compatible rendering mode is used, etc..
For many reasons, professional web designers would judge that code as
not good at all.

Once and only once you have in front of you a well written code you can
assess (and compare with other browsers) the NS 7.x DHTML performance on
one single highly-resource-demanding animation script.

DU


Your points about correct/strict page markup are of course valid but
are not the answer here.

In Netscape 7:

Why does CPU usage 'dramatically' increase when it is asked to animate
multiple divisions containing "images"?

Why does CPU usage 'dramatically' increase when it is asked to animate
multiple divisions of "any sort" over a tiled background image?

The script in question may indeed be pointless but I'm very interested
DHTML games. These N7 "oddities" are a big deal.

Below is a simple animation script as basic as you can get. It's
strict compliant and for this test, IE vs N7, is perfectly adequete.
Run it in IE and Netscape 7 as is and note their respective CPU usage.

Now add a variety of tiled backgrounds to the body tag and again check
CPU usage.

Then place any image inside the "obj" div, alter div height/width
accordingly, and check again. I look forward to reading your results.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
..division{
position:absolute;top:0px;left:0px;
height:12px;width:12px;background:#ff0000;
}
</style>
</head>
<body>

<script>
t=new Array();y=new Array();x=new Array();
for (i=0; i < 30; i++){
document.write("<div id='obj"+i+"' class='division'></div>");
y[i]=i*13;
x[i]=parseInt(Math.random()*400);
t[i]=document.getElementById("obj"+i).style;
t[i].top=y[i]+"px";
}

function ini(){
for (i=0; i < 30; i++){
x[i]++;
if (x[i] >= 400) x[i]=0;
t[i].left=x[i]+"px";
}
setTimeout("ini()",50);
}
window.onload=ini;
//-->
</script>

</body>
</html>
Jul 20 '05 #10

P: n/a
Mike wrote:
<--snip-->
In Netscape 7:

Which N7? 7.02? Its old.
Why does CPU usage 'dramatically' increase when it is asked to animate
multiple divisions containing "images"?

Why does CPU usage 'dramatically' increase when it is asked to animate
multiple divisions of "any sort" over a tiled background image?

The script in question may indeed be pointless but I'm very interested
DHTML games. These N7 "oddities" are a big deal.

Below is a simple animation script as basic as you can get. It's
strict compliant and for this test, IE vs N7, is perfectly adequete.
Run it in IE and Netscape 7 as is and note their respective CPU usage.

Now add a variety of tiled backgrounds to the body tag and again check
CPU usage.

Then place any image inside the "obj" div, alter div height/width
accordingly, and check again. I look forward to reading your results.


Nothing I added to it in Netscape 7.1 slowed it down. It may very well
be something that got 'fixed' in the later revisions/versions of NS7.
--
Randy

Jul 20 '05 #11

P: n/a
Randy Webb <hi************@aol.com> wrote in message news:<yf********************@comcast.com>...
Mike wrote:
<--snip-->
In Netscape 7:


Which N7? 7.02? Its old.
Why does CPU usage 'dramatically' increase when it is asked to animate
multiple divisions containing "images"?

Why does CPU usage 'dramatically' increase when it is asked to animate
multiple divisions of "any sort" over a tiled background image?

The script in question may indeed be pointless but I'm very interested
DHTML games. These N7 "oddities" are a big deal.

Below is a simple animation script as basic as you can get. It's
strict compliant and for this test, IE vs N7, is perfectly adequete.
Run it in IE and Netscape 7 as is and note their respective CPU usage.

Now add a variety of tiled backgrounds to the body tag and again check
CPU usage.

Then place any image inside the "obj" div, alter div height/width
accordingly, and check again. I look forward to reading your results.


Nothing I added to it in Netscape 7.1 slowed it down. It may very well
be something that got 'fixed' in the later revisions/versions of NS7.


Yeah, I'm on 7.02. Very interesting, cheers Randy. I'll see if 7.1 is
on the .net magazine disc.
Jul 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.