omg
omg

Reputation: 139842

Will all files be compressed by using ob_start("ob_gzhandler"); at line 1 with PHP?

<?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?

Upvotes: 1

Views: 613

Answers (2)

strager
strager

Reputation: 90012

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

Upvotes: 2

Sam Becker
Sam Becker

Reputation: 19636

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.

Upvotes: 6

Related Questions