Question: I have a bunch of JavaScript files that I would like to include in the page, but I don't want to have to keep writing 

```
<script type="text/javascript" src="js/file.js"></script>

```

So is there a way to include all files in a directory (unknown size)? Can I do something like...

```
$.getScript("js/*.js");

```

... to get all the JavaScript files in the "js" directory? How can I do this using jQuery?

Answer: 
@jellyfishtree it would be a better if you create one php file which includes all your js files from the directory and then only include this php file via a script tag. This has a better performance because the browser has to do less requests to the server. See this:  

*javascripts.php:*

```
<?php
   //sets the content type to javascript 
   header('Content-type: text/javascript');

   // includes all js files of the directory
   foreach(glob("packages/*.js") as $file) {
      readfile($file);
   }
?>

```

*index.php:*

```
<script type="text/javascript" src="javascripts.php"></script>

```

That's it!  

Have fun! :)
Another option that is pretty short:

```
<script type="text/javascript">
$.ajax({
  url: "/js/partials",
  success: function(data){
     $(data).find('a:contains(.js)').each(function(){
        // will loop through 
        var partial= $(this).attr("href");
        $.getScript( "/js/partials/" + partial, function( data, textStatus, jqxhr ) {});
     });
  }
});
</script>

```