Right, that (the added style) is all the optimization you need then. It's actually superior to specifying inline.
So you could change from:
HTML Code:
<div id="fadeshow1" style="width:470px; height:180px; margin-left:20px"></div>
to:
HTML Code:
<div id="fadeshow1"></div>
And add to the stylesheet (instead of what I had in my last post):
Code:
#fadeshow1, #fadeshow1 .gallerylayer img {
width: 470px;
height: 180px;
}
#fadeshow1 {
margin-left: 20px;
}
Now, whatever utility you are using to determine the optimization of the page, unless it actually gives you accurate comparative load times, there's no way you can believe it 100%.
It is good practice to specify everything you can on a page as far as dimensions go. That speeds the loading and layout and tends to prevent things jumping around on the page as it's loading. But, if taken to extremes, it can prevent the layout from being fluid enough to look good in various window sizes.
However much you do it, using style in an external stylesheet that is presumably loaded once for the entire site, or is at least getting loaded for that page anyway, is the most efficient. But it's also difficult for a utility that's simply analyzing the markup on a single page to detect. So that utility might not realize these dimensions are set. If so, it may tell you to set them, even though they are set.
But something else your utility probably doesn't know about is that this script preloads each image. It has to in order to know its dimensions and to be able to know for sure each is ready when needed. And that happens separately from loading the page, commencing with when the page's markup has been read, and proceeding apace as one image is shown, the next is preloaded. So you're probably not gaining anything in load time with any of this except for specifying the dimensions and margin of the fadeshow1 division, which to be most efficient should be done in the stylesheet as mentioned.
Optimization is fine, but sometimes you can just be spinning your wheels - wasting time on stuff that will net you a millisecond or nothing, or might even lose you a millisecond. If the page lays out without jumping around, you've probably done enough as far as specifying dimensions goes, regardless of what some utility says. You can always optimize your images, and/or your css and javascript code. Images (if you're not using multimedia stuff like Flash or audio, etc.) are the biggest thing though, optimize them to the lowest acceptable resolution/byte size, and you will save a lot on loading time for the page and its features.
Bookmarks