When you are loading JavaScript files via the <script> tag, you can only do it one-by-one, ie <script src="myFile.js"> or so I'm assuming. Is there a way to load an entire directory of .js files like src="dir/*"?
Tell me more
×
Webmasters Stack Exchange is a question and answer site for
pro webmasters. It's 100% free, no registration required.
|
|
|||
|
|
|
No - you cannot, by definition, (see RFC 1738) incorporate a wildcard into a URL. If you have server-side scripting access you could embed a block of code which inserts a script tag for every file read from a directory or you could concatenate the scripts on-the-fly (concatenation is generally preferable as it requires less overhead to download a single concatenated file). Most efficient solution: concatenate the relevant script files and link to that file from one
Here's an example of how you might do that with a PHP file named
|
||||