<?php $color = "Red"; ?> <script type="text/javascript">var color = "<?= $color ?>";</script> <script type="text/javascript" src="file.js"></script>