jkgng / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Unexpected token JS error if JS is allowed to parse PHP #259

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Are you sure this is not a problem with your configuration? (ask on the
Google Group)

Minify commit/version:2.1.5
PHP version:5.2.6-1+lenny4

What steps will reproduce the problem?
1.Add this to a JS file:
<?php header('Content-type: text/javascript'); ?>
and add this to your htaccess:
AddType application/x-httpd-php .js
2.Reference this file in your minify string
3.You will get this error:
Uncaught SyntaxError: Unexpected token <
4: If I load the file directly in the browser, it renders

Expected output:PHP parsed JS file

Actual output:JS file with PHP still in tact in the browser

Original issue reported on code.google.com by rayschwa...@gmail.com on 3 May 2012 at 6:37

GoogleCodeExporter commented 9 years ago
No JS minifiers can minify PHP syntax. You have to execute the script and 
minify the output. See:
http://code.google.com/p/minify/wiki/CustomSource#Example:_Content_from_a_URL

Original comment by mrclay....@gmail.com on 3 May 2012 at 7:06

GoogleCodeExporter commented 9 years ago
Thanks for pointing me in the right direction and apologies for posting an 
invalid issue. 
Hoping you can give me a little more insight though.
If I add this basic example to GroupsConfig:
$src1 = new Minify_Source(array(
    'filepath' => '//js/file1.js',
));
I'm told class Minify_Source can't be found in my GroupsConfig file.
Minify_Source is included in Minify which is in index.php and all of the 
examples use these and are supposed to be aded to GroupsConfig so I'm not sure 
what's wrong. If I include Minify_Source and Minify in GroupsConfig I no longer 
get those errors. I'm using the latest Minify 2.1.5.

Original comment by rayschwa...@gmail.com on 5 Jun 2012 at 3:08

GoogleCodeExporter commented 9 years ago
Discussion moved here: 
https://groups.google.com/d/msg/minify/X65A3_thsUY/BDxCUwLakCkJ
Please open a new ticket only if you've verified via the support list that this 
is a bug.

Original comment by mrclay....@gmail.com on 5 Jun 2012 at 8:08