Forum Moderators: open

Message Too Old, No Replies

is there a code so that the images load before the text?

         

essiw

1:37 pm on Oct 20, 2008 (gmt 0)

10+ Year Member



because my text gets stuck at the right side of my header, and the text is in my own made graphic border (made whit a table). so i would like to let the pictures go first, because the text isn't readable when the images are loading anyway.

rocknbil

2:55 pm on Oct 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried a Javascript preloader? Does that help it at all?

essiw

4:09 pm on Oct 20, 2008 (gmt 0)

10+ Year Member



sorry i don't know anything about javascript, only things i know are CSS and HTML

MizzBia

10:11 pm on Oct 20, 2008 (gmt 0)

10+ Year Member



I don't think there is any way to get your pictures to load before the text... at least not without some kind of script. Browsers tend to load text first because a) its just text and loads quickly so the user can start reading the page and 2) because they see images, especially backgrounds as less important then the text.

Usually pre-loaders (javascript or otherwise) help but more for cases where you have a rollover button and want to make sure the rollover image loads at the same time as everything else on your page. Even with that, text comes before images.

wrgvt

2:30 pm on Oct 21, 2008 (gmt 0)

10+ Year Member



so i would like to let the pictures go first, because the text isn't readable when the images are loading anyway.

Why is the text not readable? If you've provided dimensions for your images and done your CSS properly, then the text should load immediately into it's final rendering places on the page and then the images fill in their spots.

essiw

12:53 pm on Oct 22, 2008 (gmt 0)

10+ Year Member



@wrgvt well if you have a very slow connection speed the text is first stuck at the right of the header (don't ask me why) at least in safari that is the case.
I shall give you the css and the html ;) maybe something is wrong whit that, also maybe someone knows how to get the <center> tag out of my html? because i want to have xhtml 1.1 ;)

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="nl">
<head>
<title>Example</title>
<meta name="title" content="example" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="contact" content="info@example.com" />
<meta name="url" content="http://www.example.com/" />
<meta name="keywords" content="Example" />
<meta name="description" content="example" />
<meta name="robots" content="index, follow" />
<link href="/image2/example css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="mainheader"><!--[if lt IE 8]></div><div id="internet-explorer"><![endif]-->
<div id="header">
<div><div class="example"><center>
<img src="/image2/example.jpg" alt="" /></center></div>
<img src="/image2/foto-home.jpg" alt="example" title="" />
</div>
<div>
<div class="navlink"><img src="/image2/homev.jpg" alt="" /></div>
<div class="navlink"><a class="menukaart" href="/menukaart.html" ><img src="/image2/menukaart.jpg" alt="" /></a></div>
<div class="navlink"><a class="arrangementen" href="/arrangementen.html"><img src="/image2/arrangementen.jpg" alt="" /></a>
</div>
<div class="navlink"><a class="routebeschrijving" href="/routebeschrijving.html"><img src="/image2/routebeschrijving.jpg" alt="" /></a>
</div>
<div class="navlink"><a class="omgeving" href="/omgeving.html"><img src="/image2/omgeving.jpg" alt="" /></a></div>
<div class="navlink"><a class="contact" href="/contact.html"><img src="/image2/contact.jpg" alt="" /></a></div>
<img src="/image2/space.jpg" alt="" />
</div>
</div>
</div>

<!-- Header ends, main frame begins -->
<div class="papier">
<table cellspacing="0" cellpadding="0" border="0" >
<tr>
<td><img src="/image2/papiertje-linksboven.jpg" alt="" /></td>
<td class="papier-boven" ></td>
<td><img src="/image2/papiertje-rechtsboven.jpg" alt="" /></td>
</tr>
<tr>
<td class="papier-left"></td>
<td class="tekst">
example<br />
example".<br />
example<br />
example<p />
example,<br />
example<br />
</td>
<td class="papier-right"></td>
</tr>
<tr>
<td><img src="/image2/papiertje-linksonder.jpg" alt="" /></td>
<td class="papier-onder"></td>
<td><img src="/image2/papiertje-rechtsonder.jpg" alt="" /></td>
</tr>
</table>
</div>
</body>
</html>

body {
margin: 0px;
font: 16px "Lucida Calligraphy", "Lucida Handwriting", "Comic Sans MS";
color: #46120a;
text-align: left;
background: #bf9663 url(/image2/achtergrond-achter.jpg) repeat;
padding: 0px;
}

img {
border-width: 0;
}

a:link {
color: #46120a; text-decoration: underline}

a:visited {
color: #46120a; text-decoration: underline}

a:hover {
color: #46120a; text-decoration: none
}

a:active {
color: #46120a; text-decoration: none
}

#mainheader {
background-image: url(/image2/achtergrond-top.jpg);
width: 100%;
padding: 0px;
}

#internet-explorer {
background-image: url(/image2/achtergrond-top-IE7-.jpg);
width: 100%;
padding: 0px;

}

#header {
width: 800px;
margin-left: auto; margin-right: auto;
padding: 0px;
}

#veluws-eethuis img {
margin-left: auto; margin-right: auto;
}

#veluws-eethuis-wissel {
width: 100%;
}

.papier {
margin-top: 15px;
width: 100%;
}

.papier table { margin-left: auto; margin-right: auto;}

.papier-boven {
background-image: url(/image2/papiertje-boven.jpg);
width: 700px;
}

.papier-onder {
background-image: url(/image2/papiertje-onder.jpg);
width: 700px;
}

.papier-left {
background-image: url(/image2/papiertje-left.jpg);
}

.papier-right {
background-image: url(/image2/papiertje-right.jpg);
}

.tekst {
background-image: url(/image2/achtergrond2.jpg);
width: 700px;
}

.navlink {
float: left;
margin: 0px;
padding: 0px;
}

a.home
{width:109px; height:42px; display:block;
background-image:url(/image2/homev.jpg);}
a.home:hover
{background-image:url(/image2/homev.jpg);}
a.home:hover img {visibility: hidden;}

a.menukaart
{width:120px; height:42px; display:block;
background-image:url(/image2/menukaartv.jpg);}
a.menukaart:hover
{background-image:url(/image2/menukaartv.jpg);}
a.menukaart:hover img {visibility: hidden;}

a.arrangementen
{width:152px; height:42px; display:block;
background-image:url(/image2/arrangementenv.jpg);}
a.arrangementen:hover
{background-image:url(/image2/arrangementenv.jpg);}
a.arrangementen:hover img {visibility: hidden;}

a.omgeving
{width:114px; height:42px; display:block;
background-image:url(/image2/omgevingv.jpg);}
a.omgeving:hover
{background-image:url(/image2/omgevingv.jpg);}
a.omgeving:hover img {visibility: hidden;}

a.routebeschrijving
{width:167px; height:42px; display:block;
background-image:url(/image2/routebeschrijvingv.jpg);}
a.routebeschrijving:hover
{background-image:url(/image2/routebeschrijvingv.jpg);}
a.routebeschrijving:hover img {visibility: hidden;}

a.contact
{width:100px; height:42px; display:block;
background-image:url(/image2/contactv.jpg);}
a.contact:hover
{background-image:url(/image2/contactv.jpg);}
a.contact:hover img {visibility: hidden;}

[edited by: engine at 1:14 pm (utc) on Oct. 22, 2008]
[edit reason] no specifics: examplified [/edit]

essiw

12:58 pm on Oct 25, 2008 (gmt 0)

10+ Year Member



anyone?

londrum

7:48 pm on Oct 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you could try giving the image some dimensions (
<img src="blah.jpg" width="100" height="100" />
etc), so the browser knows how big it is and can plan the page out before it's loaded.

swa66

8:11 pm on Oct 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"Loading" needs to be properly defined.

If you meant getting it from the server: the text of a page is most likely in the html of the page and as such it will be downloaded with the html. Since the CSS, images and other media are linked from the html or the CSS (background images) the text will be necessity always be loaded first.
Browsers decide on their own what gets loaded first once they have the html. Most will first go for the CSS first.
Know that HTTP 1.1 connections (should be most of them nowadays) will only open 2 concurrent connections, not the typical 10 connections from HTTP 1.0 anymore.

If you meant what gets displayed in what order, you can speed it up a but for slow connections by doing some tricks like making sure all images have a size set (so the flow can be done and the text positioned without having the images already downloaded.

Also using things like CSS sprites can seriously reduce the download time as getting a single image will be faster than getting a lot of them in modern browsers.
Most users do not like the flash of un-styled content that would happen due to the CSS being loaded after the html (be necessity), and hence browsers seem to hold off on displaying the text somewhat till they got hold of the CSS (within limits).

I think you have a number of things to aim for, that each might give you a partial solution:

  • Use css for layout instead of (ab)using tables
  • Make the site more efficient (smaller download size) to make it load faster. Take a look at [webmasterworld.com...] for ideas.
  • Get a faster webserver if that's possible or part of the problem
  • webkit (safari and chrome) implemented some pre-CSS3 transitions and animations, perhaps some of those can help [I've not played with any of them yet, so I'm guessing here]
    [w3.org...]
    [w3.org...]
  • Try to make your site also be readable or even make it also look good without layout applied to it (pretty hard with a table based layout, reasonably easy with CSS properly used)

Good luck.

essiw

9:16 pm on Oct 25, 2008 (gmt 0)

10+ Year Member



thanks for your advice, I will set image sizes that could probably do the trick, is it possible to set image sizes in css? and if it is, how? or could i better put them in the <img> tag?
also you told me not to use tables, i tried to do that, but whit no luck, i have an image border and that is why i use a table. whitout them i just get errors, because then i get these things: top and bottom border can't change size when you make your window smaller & background does not appear inside the image borders if there is no text (so there was some space in there...), so i will wait untill CSS3 whit image-borders comes out before deleting tables ;). but i think setting image sizes would help already

alt131

12:09 am on Oct 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi essiw,

because the text isn't readable when the images are loading anyway.
If that is because the colour of the text is only readable after the images provide a contrasting background, then give the element a background-color that makes the text readable while the images are downloading. Providing a background-colour that makes text readable without images is a good coding practise - and as a user may have images turned off, or they may not download, quite important.

I will set image sizes that could probably do the trick, is it possible to set image sizes in css? and if it is, how? or could i better put them in the <img> tag?
For images in the html, best coding practise is to put the dimensions into the image element. As londrum said, this allows the browser to identify the space required by the image and layout the page accordingly, even if the image has not yet been downloaded. Aim to code in a way that works "with" the browser rather than trying to force the browser to do things to overcome code deficiencies.

If you are using one, "full-size"image for each background image in the css, then the image dimensions are already known to you. Help the browser out by putting the dimensions into the css via "height" and width". If you can, make it even easier for the browser by setting a height and width on the cells.

also you told me not to use tables, i tried to do that, but whit no luck,
This is possible, although it might seem difficult at first if used to using tables. It will also depend on what you are trying to achieve. The provided code suggests images being used to convey meaning (such as for links) rather than text. If the site does use images that way, then my opinion is that utter enormity of the accessibility and seo disadvantages make the additional issue of "tables for layout" barely worth a mention.

because my text gets stuck at the right side of my header
On the provided code, for me, both winSafari and ff draw the table in div.papier to the right of the document (although below the header), rather than centred full width - which is what I think you wanted. This is despite div.papier itself being drawn below the header and centered. I cannot immediately see the exact cause, but applying
clear:left
to
.papier
in your css fixes the issue.

how to get the <center> tag out of my html
There are several ways to do this, but because div.example only contains an image, remove the <center> and create a new class in your css:
.example {text-align:center}

I shall give you the css and the html maybe something is wrong whit that, ... because i want to have xhtml 1.1
Your html and css both validated, which is fantastic! So, technically, there is nothing "wrong" with either. However, the html suffers from "divitis" and "classitis", and the css has lots of redundancies, so could easily be improved. However, as said earlier, I think these are minor considerations if the site is using images to convey information.

Unless you have some real reason (and that's not apparent in the provided code) for xhtml, then I suggest you aim for html strict. Why most of us should NOT use XHTML [webmasterworld.com] and Choosing the best doctype for your site [webmasterworld.com] have good discussions on the issue.

tangor

6:39 am on Oct 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sometimes the obvious gets overlooked: All browsers will leave space for a table but display nothing until the table contents are fully loaded. CSS only does not have that problem. Otherwise than some redundancies in the code, it looks okay.

phranque

7:28 am on Oct 27, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would recommend reading the following WebmasterWorld threads for more information:
Speeding Up Your Site - best practices for the front end [webmasterworld.com]
Image Optimization: Are you still concerned about your image file sizes? [webmasterworld.com]

martinibuster

7:44 am on Oct 27, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi essiw, :)
Nesting DIVs (and TABLES) slows down the rendering. Experiment with rewriting your code with less nesting. Browsers render them one at a time. Nothing gets rendered until it gets to the closing tag. While yours is not an extreme case of it, there's still some nesting going on. Try to rewrite the code without nesting.

Code created in blocks that strictly follows a top to bottom hierarchy (visually) renders the fastest.

Here is the ideal layout (IMHO):

<body>
<div>
logo image + some keyword laden slogan
</div>
<div>
nav bar
</div>
<div>
Content including H1 etc.
</div>
<div>
Footer stuff
</div>
</body>

Naturally the middle content area is where you're going to have some contexually related navigational links related to what section you are and nesting that in there isn't going to slow things down much at all. What you want to avoid is avoidable nesting. It can be done. ;)

essiw

3:10 pm on Oct 27, 2008 (gmt 0)

10+ Year Member



@martinibuster
i understand that nesting slows it down I need it in this case, because: i have a background image for the whole header, (cutting it up gives a lot of problems especially whit IE7-), and all the <div>'s you see whit one image are because of a mousover (floating to the left). I only can delete one <div> right now because i didn't know how to center it, and someone just answered it :) so that is one <div> less

essiw

3:28 pm on Oct 27, 2008 (gmt 0)

10+ Year Member



@alt131
the text is readable at the background image and even at the set-up background color if the background doesn't load

ok thanks i will put them in the <img> tag
don't know exactly what you said about full sized imaged (since english is my second langluage and i am still learning it at school), but there aren't full sized so it doesn't really matter ;)

well what i use my table for is an image-border. which the top, bottem, right and left side can become smaller when you are making your window smaller, this is possible whit css i heard from someone, but then whit 10 <div>'s which won't speed anything up at all. When css3 is out then it will be easy to implent ;) (it has an image border option)

actually the strange thing is it loads at the right side of an image in the header, which is in a whole other <div> tag and the text is even in a <table> tag. but i try clearing it to the left :)

yeah i know the css has some redundancies but those aren't that big (some margin etc. things aren't needed, but i don't know which ones)
and only the hyperlinks tot the other pages are picture-links ;)

Well i did look at your links about xhtml, and read a bit, but it is not that easy for me to understand it all. all i understood that was there was that you easely make mistakes whit uppercase and "/" etc. but i never made those so... and that there is nearly an extra in xhtml. but i don't see any negative things what would go for me. it is that i like xhtml because it has to be clean typed (no uppercase and to close everything) and that about:_blank does not work etc. is also positive for me. it makes the internet much cleaner.

thanks for your help :)

essiw

3:35 pm on Oct 27, 2008 (gmt 0)

10+ Year Member



@phranque I have read them but since english is not my first langluage i did not understand 3 things in there, could someone explain them for me ? thanks in advance ;)

2. Use a Content Delivery Network
3. Add an Expires Header
4. Gzip Components

tedster

6:28 pm on Oct 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Those are steps that you can take on your server - and each one is a big discussion, often related to what specific kind of server you use.

They are each factors in the Yslow tool that we discused here: [webmasterworld.com...]

If you follow the links in that thread, you'll begin to learn about each of those areas.

essiw

6:08 pm on Oct 29, 2008 (gmt 0)

10+ Year Member



thanks to all ^^ problems are solved, exept that there is one new problem, i don't know how it could have happened... In IE7 and lower the pictures in the header seems all lower then they have to be (like there is a 10-20px padding at the top..., (the header background is still there)

html:
<div id="mainheader"><!--[if lt IE 8]></div><div id="internet-explorer"><![endif]-->
<div id="header">
<div>
<img src="/image2/veluwseethuiswissel.jpg" width="270" height="43" alt="" />
<img src="/image2/foto-home.jpg" width="800" height="165" alt="veluws eethuis wissel" title="" />
</div>
<div>
<div class="navlink"><img src="/image2/homev.jpg" width="109" height="42" alt="" /></div>
<div class="navlink"><a class="menukaart" href="/menukaart.html" ><img src="/image2/menukaart.jpg" width="120" height="42" alt="" /></a></div>
<div class="navlink"><a class="arrangementen" href="/arrangementen.html"><img src="/image2/arrangementen.jpg" width="152" height="42" alt="" /></a></div>
<div class="navlink"><a class="routebeschrijving" href="/routebeschrijving.html"><img src="/image2/routebeschrijving.jpg" width="167" height="42" alt="" /></a></div>
<div class="navlink"><a class="omgeving" href="/omgeving.html"><img src="/image2/omgeving.jpg" width="114" height="42" alt="" /></a></div>
<div class="navlink"><a class="contact" href="/contact.html"><img src="/image2/contact.jpg" width="100" height="42" alt="" /></a></div>
<img src="/image2/space.jpg" width="38" height="42" alt="" />
</div>
</div>
</div>

css:
body {
margin: 0px;
font: 16px "Lucida Calligraphy", "Lucida Handwriting", "Comic Sans MS";
color: #46120a;
text-align: left;
background: #bf9663 url(/image2/achtergrond-achter.jpg) repeat;
padding: 0px;
}

img {
border-width: 0;
}

#mainheader {
background-image: url(/image2/achtergrond-top.jpg);
width: 100%;
padding: 0px;
background-repeat: repeat-x;
}

#internet-explorer {
background-image: url(/image2/achtergrond-top-IE7-.jpg);
width: 100%;
padding: 0px;
background-repeat: repeat-x;
}

#header {
width: 800px;
margin-left: auto; margin-right: auto;
padding: 0px;
}

#header div{
text-align:center;
}

/* mousover css */

.navlink {
float: left;
margin: 0px;
padding: 0px;
}

a.home
{width:109px; height:42px; display:block;
background-image:url(/image2/homev.jpg);}
a.home:hover
{background-image:url(/image2/homev.jpg);}
a.home:hover img {visibility: hidden;}

a.menukaart
{width:120px; height:42px; display:block;
background-image:url(/image2/menukaartv.jpg);}
a.menukaart:hover
{background-image:url(/image2/menukaartv.jpg);}
a.menukaart:hover img {visibility: hidden;}

a.arrangementen
{width:152px; height:42px; display:block;
background-image:url(/image2/arrangementenv.jpg);}
a.arrangementen:hover
{background-image:url(/image2/arrangementenv.jpg);}
a.arrangementen:hover img {visibility: hidden;}

a.routebeschrijving
{width:167px; height:42px; display:block;
background-image:url(/image2/routebeschrijvingv.jpg);}
a.routebeschrijving:hover
{background-image:url(/image2/routebeschrijvingv.jpg);}
a.routebeschrijving:hover img {visibility: hidden;}

a.omgeving
{width:114px; height:42px; display:block;
background-image:url(/image2/omgevingv.jpg);}
a.omgeving:hover
{background-image:url(/image2/omgevingv.jpg);}
a.omgeving:hover img {visibility: hidden;}

a.contact
{width:100px; height:42px; display:block;
background-image:url(/image2/contactv.jpg);}
a.contact:hover
{background-image:url(/image2/contactv.jpg);}
a.contact:hover img {visibility: hidden;}

essiw

6:13 pm on Oct 29, 2008 (gmt 0)

10+ Year Member



oh and the <!--[if lt IE 8]></div><div id="internet-explorer"><![endif]--> is because i has this problem before, and fixed it with an other background image, but now it is there again...