| Coding Forum Problems with your code? Let's hear about it. |
08-08-2006, 02:57 PM
|
#1 (permalink)
|
|
Inactive
Join Date: 04-11-06
Posts: 28
Latest Blog: None
|
script to load images and js after the page loads ??
hello
i run http://sprinj.com and the biggest problem right now is that pages weigh in average 300kb which is way too much for me.
so i was wondering if there is any script out there who will load ressources like jpegs, png, javascripts, css like a few seconds after the html page is loaded, so that the user can see the page is coming and he can read something meanwhile all other ressources are loaded in the background

|
|
|
08-08-2006, 10:13 PM
|
#2 (permalink)
|
|
Inactive
Join Date: 06-16-06
Posts: 268
Latest Blog: None
|
This can be done through some javascript. However, an easier way is to put all your javascript in an external file, and use CSS for the styling (and keep that in an external file too).
|
|
|
08-10-2006, 07:34 AM
|
#3 (permalink)
|
|
Inactive
Join Date: 03-29-06
Posts: 548
|
Can I ask why it is about 300kb?
|
|
|
08-10-2006, 02:44 PM
|
#4 (permalink)
|
|
Inactive
Join Date: 04-11-06
Posts: 28
Latest Blog: None
|
Quote:
|
Originally Posted by Mrblogs
Can I ask why it is about 300kb?
|
well the html pages are very light, but the javascripts weighs quite a lot (about 200kb it depends on the page) and then there are the images used for the layout.
I have just used a javascript compressor and saved 50 kb  but still i would like to find something that can load ressources in the background , if thast exists
|
|
|
08-10-2006, 06:01 PM
|
#5 (permalink)
|
|
Inactive
Join Date: 06-16-06
Posts: 268
Latest Blog: None
|
Joewall,
dude, you really need to put all your javascript in another file and remove it from the HTML. Then, where it says the javascript right now, put this line:
PHP Code:
<script type="text/javascript" src="/path-to-file/javascript.js"> </script>
This would get you rid of all the javascript showing up in the HTML code as you would put it all in the file "javascript.js".
|
|
|
08-11-2006, 03:34 AM
|
#6 (permalink)
|
|
Inactive
Join Date: 03-29-06
Posts: 548
|
There is some serious coding going on to require 200kb of Javascript.. o_O
|
|
|
08-11-2006, 12:07 PM
|
#7 (permalink)
|
|
Inactive
Join Date: 04-11-06
Posts: 28
Latest Blog: None
|
Quote:
|
you really need to put all your javascript in another file and remove it from the HTML.
|
actually there are no javascripts in my html code, they are all in external files.
Quote:
|
There is some serious coding going on to require 200kb of Javascript.. o_O
|
 the truth is i do really need those 200kb javascripts. (ajax functions, a calendar, text editing...)
|
|
|
08-12-2006, 12:01 PM
|
#8 (permalink)
|
|
Inactive
Join Date: 06-06-06
Location: New York, NY
Posts: 586
Latest Blog: None
|
JoeWall:
Quote:
|
the truth is i do really need those 200kb javascripts. (ajax functions, a calendar, text editing...)
|
Given the URL you posted, I can't see that any of those things takes place on that page. Howzabout just loading each as needed? Given that the majority of the world is still on dialup (sigh), and that most folks haven't got a lotta RAM or a whole lotta processing power, they'll be hard-pressed to load your pages if you're bogging 'em down with all kindsa features they won't be making use of at any given moment.
|
|
|
08-15-2006, 08:29 AM
|
#9 (permalink)
|
|
Inactive
Join Date: 03-29-06
Posts: 548
|
Javascript should be loaded as needed, same with CSSs.
HTML is flexible enough to do so.
It would then also be easier to create a script to load images.
|
|
|
08-17-2006, 01:16 AM
|
#10 (permalink)
|
|
Inactive
Join Date: 06-16-06
Posts: 268
Latest Blog: None
|
Quote:
|
Originally Posted by JoeWall
actually there are no javascripts in my html code, they are all in external files. 
|
Oh, I thought the actual output of each page is 200KB because you put all the javasvript in the same place. That would give you serious issues with the search engines too. 
|
|
|
08-17-2006, 02:05 PM
|
#11 (permalink)
|
|
Inactive
Join Date: 04-11-06
Posts: 28
Latest Blog: None
|
Quote:
|
Originally Posted by Mrblogs
Javascript should be loaded as needed, same with CSSs.
HTML is flexible enough to do so.
It would then also be easier to create a script to load images.
|
but is there a name for this kind of script. i have searched on google but nothing that looks like what i want. for example a script that loads heavy ressources like 10 seconds the page is loaded.
|
|
|
08-17-2006, 02:24 PM
|
#12 (permalink)
|
|
Inactive
Join Date: 06-06-06
Location: New York, NY
Posts: 586
Latest Blog: None
|
|
|
|
08-18-2006, 07:15 AM
|
#13 (permalink)
|
|
Inactive
Join Date: 03-29-06
Posts: 548
|
It is just a matter of using the appropriate display attributes for the style element of divs.
Put a DIV around the contents of the site, and initially set it to "display: none;"
then create another div, with some "loading please wait" text in and set that to display: block;
then on the OnLoad of the page, run your javascript script that loads all the images in one by one, then change the displays of the divs around.
|
|
|
08-18-2006, 10:45 AM
|
#14 (permalink)
|
|
Inactive
Join Date: 04-11-06
Posts: 28
Latest Blog: None
|
Quote:
|
Originally Posted by Mrblogs
Put a DIV around the contents of the site, and initially set it to "display: none;"
then create another div, with some "loading please wait" text in and set that to display: block;
then on the OnLoad of the page, run your javascript script that loads all the images in one by one, then change the displays of the divs around.
|
that surely looks for the tip i was looking for, will be testing it right away. thanks!
thanks i have seen it looks good too.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:55 PM.
© Copyright 2008 V7 Inc
|