Basic question:
How to include a script.min.js
in an external php file.
My current setup:
index.php
<script type="text/javascript" src="http://localhost/js.php"></script>
js.php
<?php
header('Content-type: text/javascript');
include "script1.js"; echo "
";
include "script2.js"; echo "
";
include "script3.js"; echo "
";
?>
Long Question:
I've ran into this issue a couple times over the years and ignored it by including it as a separate <script src=""></script>
but it's time to find out if there is a solution.
Occasionally I'll run into a javascript file that doesn't work when included. Just produces javascript errors. (I've tried echo file_get_contents(...) also)
My current script is tinymce.min.js
.
As above it works fine if included <script src="tinymce.min.js"></script>
after my js.php
file. But included in the php file does not work.
Shouldn't be relavent as it's not the first minified script to not work. But the current error recieved in Firefox console is TypeError: c is not a constructor
Side question, should I be using Content-type: application/javascript
since I'm only catering for modern browsers?