Erwin
Erwin

Reputation: 1772

Slow Loading of Page

I'm getting JavaScript errors for all my links that contain JavaScript events. This is caused by the user trying to click on a link, and yet the JavaScript files have not been loaded yet.

How can I resolve this issue? Is there any way of blocking the JavaScript events until all the JavaScript files are loaded?

Upvotes: 1

Views: 211

Answers (3)

egrunin
egrunin

Reputation: 25053

The conventional way of handling this is to hide the page content behind a DIV until the onLoad() event fires, then reveal it by hiding the DIV.

Edited to add

I see his problem as not being specifically about javascript, but the general problem of keeping the user from interacting with the page before it's loaded.

Upvotes: 0

Jason McCreary
Jason McCreary

Reputation: 72991

JavaScript blocks natively. Just ensure that your scripts are loaded before your links, i.e. within the head tag.

The above should fix it, but you should look into Progressive Enhancement

Upvotes: 1

Noon Silk
Noon Silk

Reputation: 55082

If the code for whatever you're doing is declared above the link (i.e. the place where the code is used) you should not have this problem.

I'm unsure how different browses will handle the order of loading if the JavaScript is in an external file.

Upvotes: 1

Related Questions