Support PHP in external Javascript

The Problem Have you ever tried to write code like this? external.js function test_javascript() { console.log( ‘Currently at page: <?php echo $_SERVER[‘SCRIPT_URI’] ?>’ ); } index.php <script src=”external.js”></script> Most of the time, you will find that the external.js file will have an error because it cannot make sense of the PHP snippet. ┬áThe following is…