...

View Full Version : performace of the website when externalising code



suhayda
03-12-2004, 10:37 AM
Could it be that when I call the different type of java code it really slows down my website? It seems to taka much much longer to load...

let me know if there are better ways to import the code.

The reason why I do it is because of search engine optimization. Most search engines assign a greater value to the lines of code on top, so the more javascript I have on top, the less value my main page content has.

Please share your thoughts.

Thanks

swmr
03-12-2004, 10:47 AM
I don't know about the importing, but the code can be placed at the bottom of the document...

suhayda
03-12-2004, 11:18 AM
thanks anyways...

Kor
03-12-2004, 12:58 PM
As far as I know search engines do not search inside the javascript or CSS code, so you don't have to worry about that.



the code can be placed at the bottom


Yes, but is a better ideea to put the code in head, as the head is loaded first, and you may need some of those codelines to set up something in body onload.

Anyway, you may use external JS files to reduce the size of the head, if you want it so...

swmr
03-12-2004, 06:01 PM
Originally posted by Kor
put the code in head, as the head is loaded first, and you may need some of those codelines to set up something in body onload.
Is that really a factor?

I haven't observed any differences between this:
<head>
<title> - </title>
<script type="text/JavaScript">
// code...
</script>
</head>

and this:
<body>
<p>content...</p>
<p>content...</p>
<p>content...</p>
<p>content...</p>
<script type="text/JavaScript">
// code...
</script>
</body>


How would the onload event be adversely effected by lower code placement?

Kor
03-12-2004, 06:47 PM
do smthlike

<body onload="afunction()">
and that function called somewhere

<script code here>
</body>

an , on a slow connection you will know what I mean.

The loading system is a sequential one. If good speed, no notable difference (well, no lazy-eyed...:D ) if medium/slow speed... hm

swmr
03-12-2004, 07:28 PM
ah, I hadn't tried that...

wouldn't calling document.body.onload = function afunction(){//code} as the last task before </script> correct for slow loading?

Kor
03-15-2004, 08:56 AM
wouldn't calling document.body.onload = function afunction(){//code} ...


...in fact
window.onload = afunction;
or
window.onload = function(){afunction(parameter_if_needed)}

Yes, this will correct the problem, if this line is the last code's line.

But, I repeat, at least as long as the script is inner quoted by "nonhtml" commentaries as
<script>
<!--
..code lines here
-->
</script>

The search engines will jump over the code, as they search only in HTML code lines, in fact only text in HTML code.

Furthermore, if the script (javascript or CSS) is clearly maked up in tag as a special type, the search engines will jump the script as well.

<script language="JavaScript" type="text/JavaScript">
<style type="text/css">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum