What is the correct syntax for adding an external reference to a JavaScript file (.js) within another JavaScript file?
+4
A:
There isn't any.
You can add a <script>
block to the document, but it will execute asynchronously.
SLaks
2010-10-18 22:15:10
Assuming of course he's using JavaScript on a browser. ;-)
T.J. Crowder
2010-10-18 22:17:44
@Michael: If you aren't (using JavaScript on a browser), you'll have to use whatever mechanisms exist in your environment that allow you to load code. There's bound to be something, even if (in the absolute worst case) it's loading the file as text and then eval'ing it.
T.J. Crowder
2010-10-18 22:18:36
I was able to add a reference to the java script in some of the HTML code managed through the UI.
Michael Kniskern
2010-10-18 22:34:54
A:
Alternatively store all your .js files in a php file.
<script src="js.php" type="text/javascript"></script>
php:
<?php
require 'js/myjs1.js';
require 'js/myjs2.js';
?>
woodscreative
2010-10-18 22:20:10