Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2005051

Re: [PHP] Reducing size of htm output From: Andy Pieters (mailings <email protected>)
Date: 05/08/05

On Friday 06 May 2005 19:59, Kirsten wrote:
> I need to reduce the size of the HTM generated by a PHP script for faster
> transmission. I'm actually using ob_start("ob_gzhandler") but I also need
> some function to reduce the size of javascript blocks, deletion of
> unnecesary blanks, etc.

Hi Kirsten,

You know, PHP can be used to create all kinds of files "on the fly". It is
not limited to html files.

I would suggest you rewrite your javascript into a seperate file.

<?php
 header("Content-Type: text/javascript");
 $action=@ intval($_GET['function']);
 switch ($action)
 {case 0: echo <<<_firstpart
function first(e)
{blablaabla
}
_firstpart;
 break;
        } ?>

When you need to call javascript functions, include them like this: <script
type="text/javascript" src="myscript.js.php?function=0"></script>

With this scheme, the browser can cache the different bits of the script, and
you don't need to send all of the script on each page hit.

Kind regards

Andy

-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php