1

In php there is a

<?php include("file.php"); ?>

Is there an equivalent in javascript.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
JMD
  • 43
  • 1
  • 7
  • php.js is the answer http://phpjs.org – jmingov Mar 08 '14 at 16:21
  • Which environment are you using JavaScript in? In a browser? On a server using Node.js? There are different techniques for each. – clinton3141 Mar 08 '14 at 16:23
  • browser. And no jquery – JMD Mar 08 '14 at 16:24
  • 1
    Take a look at require.js -> http://requirejs.org/ – blgt Mar 08 '14 at 16:32
  • 1
    possible duplicate of [How to include a JavaScript file in another JavaScript file?](http://stackoverflow.com/questions/950087/how-to-include-a-javascript-file-in-another-javascript-file). See also https://stackoverflow.com/questions/16297688/load-javascript-like-phps-include or http://stackoverflow.com/questions/21294/dynamically-load-a-javascript-file-think-of-include-in-c – Bergi Mar 08 '14 at 16:49

2 Answers2

0

You could look at using an asset precompilation framework such as Broccoli.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
0

Yes. It is :

<script src="path-to-your-js"></script>

Or you can take a look at Require.js

Serge K.
  • 5,303
  • 1
  • 20
  • 27