tags:

views:

220

answers:

2
<?php
ob_start("ob_gzhandler");
?>
<script type="text/javascript" src="Util.js"></script>
<script type="text/javascript" src="connection.js"></script>
....
<?php ob_end_flush(); ?>

Will the files included by or also be compressed?

+1  A: 

When you use an output buffering filter such as ob_gzhandler, it applies only to that specific request. It does not affect other requests a browser may make.

However, from what you have shown, it cannot be determined if Util.js and connection.js will be gzipped or deflated or something else. That's up to the configuration of the server and if files are actually scripts which gzip the content.

(Also, make sure the browser claims to accept gzipped content, and that you tell the browser you are sending gzipped content. You could send gibberish to a browser on accident!)

Short answer: no

strager
+5  A: 

Not in the HTML, no. Those files are request by the browser and the PHP script has no direct relationship with them. You would have to manually rewrite those javascript files to a PHP script that preforms the same action.

Sam152
Probably better to just reconfigure Apache/IIS/whatever to compress static files like stylesheets and JS. Checkout mod_deflate: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
carl