PDA

View Full Version : Want to shrink your TGP's?


swedguy
2005-02-26, 11:05 AM
No, not make them smaller, but at least shrink the file size and make them load faster :)

I was going through one of my script folders and found a javascript I used when I had TGP's. I was never a fan of having something random in the status bar. So the solution was to have an onmouseover + onfocus on all links, which made the pages HUGE. A regular link would look something like this:

<a href="thumbs.php?pct=85&link=pic3&url=http://www.gallerydomain.com/00276197-01-01/pictures/05/index.php" onMouseover="window.status='http://www.gallerydomain.com/00276197-01-01/pictures/05/index.php'; return true;" onFocus="window.status='http://www.gallerydomain.com/00276197-01-01/pictures/05/index.php'; return true;" onMouseout="window.status=''>

That link is 355 bytes.

Now lets change it to something smaller

<a href="thumbs.php?pct=60&link=pic47&url=http://www.gallerydomain.com/00276197-01-01/pictures/05/index.php" onMouseover="ds(href);return true" onFocus="ds(href);return true" onMouseout="os()">

That link is 193 bytes.

What you need to put between your <head> and </head> is this:

<script>
function ds(msg) {
var surl = msg.match(/url=([^&]*)/, "$1")
status=unescape(surl[1])
}
function os() {
status=''
}
</script>


So if your TGP has 300 links you would save 47kB. That's a lot of load time if you're on a modem :)

HarryM
2005-02-27, 01:35 AM
hey thanks, I needed something like that :)

Joe
2005-03-08, 08:02 AM
Nice tip, thanks!

If you're really anal about bandwidth, you can also use an HTML shrinker (or HTML compressor) that removes all the whitespace.

pcum
2005-03-24, 02:05 PM
Just what I needed thanks man great tip