Forum Moderators: open

Message Too Old, No Replies

javascript speed

         

rhodopsin

7:35 am on Sep 26, 2004 (gmt 0)

10+ Year Member



RE: Speeding javascript execution

This Q is related to a javascript script called geodirection. Can be found at:

[geobytes.com...]

However, this Q is more general in that it is about how to speed javascript execution.

GeoDirection is a free javascript that dynamically redirects internet surfers based on their geographic location.

I am having some problems with geodirection in terms of the speed at which it acts.

Basically - I have a default web page for one geographical area, geographical area A. This web page being, page A.

Surfers from geographical area B are transferred to a different web page, away from the default. This web page being page B.

This works - however, it takes quite a while for the transfer to take place. People from area B can see the default web page, A, whilst they are waiting to be transferred to web page B.

This is bad.

POSSIBLE SOLUTION?
Is there any way that I can optimise the code such that the transfer protocol is executed before the text and images of website A, the default web page, is displayed?

SO THE GENERAL Q IS - HOW CAN I MAKE IT SO THAT THE JAVASCRIPT IS EXECUTED BEFORE THE HTML. THE HTML IS ONLY EXECUTED AFTER THE JAVASCRIPT HAS FINISHED?

I have been putting the javascript in the <head> <head> section of the HTML file.

Would be ever so grateful for some help with this.

dcrombie

11:17 am on Sep 26, 2004 (gmt 0)



You can't. JavaScript is only executed as the HTML page is loading. The user will ALWAYS see some or all of the content of that page.

You need to use server-side technologies (eg. PHP or mod_rewrite) to avoid this.

Rambo Tribble

1:45 pm on Sep 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The lag you are experiencing isn't from the JavaScript, anyway. It's from GeoBytes' server.