469,358 Members | 1,651 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

javascript too slow

Hi Folk

Please have a look at http://www.photowarehouse.co.nz/index.php (and
especially the menus on the side)

JS hides the menu items, but it does so too slow. If I put the
display: none; in the css then the default open menus are closed.

It is all sooooo complex to me, so I cant really explain how it all
works. Can someone perhaps tell me how to get the JS to kick-in
earlier to hide the menu? I can not use css, because when I use css
then if people have JS turned off, the menu will not show ever.

I tried writing css in the header of the html with javascript, but that
did not solve anything.

The following function runs onload:

var displayarray = new Array("none", "block");
var elementarray = new Array("ful", "catul", "brandul", "infoul");
var elementType = "img";

function bodyloader() {
for(i = 0; i < elementarray.length; i++) {
if(document.getElementById(elementarray[i])) {
var elementname = elementarray[i];
document.getElementById(elementarray[i]).style.display = "none";
}
}

it hides all the menus, but it just seems to take for africa, before it
actions.

Thank you

Nicolaas

Dec 6 '06 #1
2 1492

windandwaves wrote:
Hi Folk

Please have a look at http://www.photowarehouse.co.nz/index.php (and
especially the menus on the side)

JS hides the menu items, but it does so too slow. If I put the
display: none; in the css then the default open menus are closed.

It is all sooooo complex to me, so I cant really explain how it all
works. Can someone perhaps tell me how to get the JS to kick-in
earlier to hide the menu? I can not use css, because when I use css
then if people have JS turned off, the menu will not show ever.

I tried writing css in the header of the html with javascript, but that
did not solve anything.

The following function runs onload:

var displayarray = new Array("none", "block");
var elementarray = new Array("ful", "catul", "brandul", "infoul");
var elementType = "img";

function bodyloader() {
for(i = 0; i < elementarray.length; i++) {
if(document.getElementById(elementarray[i])) {
var elementname = elementarray[i];
document.getElementById(elementarray[i]).style.display = "none";
}
}

it hides all the menus, but it just seems to take for africa, before it
actions.

Thank you

Nicolaas
Hi

I am only an amateur at this, but your problem is not that the
JavaScript is slow as such, but that the "onload" event only fires when
all of the HTML and pictures have loaded (although browsers vary on
this I think).

In terms of solutions, one option is to find some way of detecting the
point at which your menu has loaded and is interactive (before any
other content or pictures).

You could look at:-

(a) Inserting an empty element at the end of your menu tags, and
using setInterval to spot when it is loaded, indicating that the rest
of the menu is ready.

(b) Some of the solutions proposed by the Yahoo UI library (see
another recent post from Peter Michaux on this subject).

(c) Look at some of the ideas on this page

<URL:http://dean.edwards.name/weblog/2006/06/again/>

(d) See if there is a JavaScript/css solution, such as having two
different style sheets, and disabling the one display:block if
JavaScript is available.

I am sure others will have better, more elegant ideas.

Regards

Julian

Dec 6 '06 #2

Julian Turner wrote:
windandwaves wrote:
Hi Folk

Please have a look at http://www.photowarehouse.co.nz/index.php (and
especially the menus on the side)

JS hides the menu items, but it does so too slow. If I put the
display: none; in the css then the default open menus are closed.

It is all sooooo complex to me, so I cant really explain how it all
works. Can someone perhaps tell me how to get the JS to kick-in
earlier to hide the menu? I can not use css, because when I use css
then if people have JS turned off, the menu will not show ever.

I tried writing css in the header of the html with javascript, but that
did not solve anything.

The following function runs onload:

var displayarray = new Array("none", "block");
var elementarray = new Array("ful", "catul", "brandul", "infoul");
var elementType = "img";

function bodyloader() {
for(i = 0; i < elementarray.length; i++) {
if(document.getElementById(elementarray[i])) {
var elementname = elementarray[i];
document.getElementById(elementarray[i]).style.display = "none";
}
}

it hides all the menus, but it just seems to take for africa, before it
actions.

Thank you

Nicolaas

Hi

I am only an amateur at this, but your problem is not that the
JavaScript is slow as such, but that the "onload" event only fires when
all of the HTML and pictures have loaded (although browsers vary on
this I think).

In terms of solutions, one option is to find some way of detecting the
point at which your menu has loaded and is interactive (before any
other content or pictures).

You could look at:-

(a) Inserting an empty element at the end of your menu tags, and
using setInterval to spot when it is loaded, indicating that the rest
of the menu is ready.

(b) Some of the solutions proposed by the Yahoo UI library (see
another recent post from Peter Michaux on this subject).

(c) Look at some of the ideas on this page

<URL:http://dean.edwards.name/weblog/2006/06/again/>
Thanka a million Julian! I used the method above and it works a treat
- from what I can see!

Thank you again.

Nicolaas

Dec 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.