Search code examples
javascriptweb-applicationsincludeorganizationcode-structure

Can I include another source file in JavaScript?


I'm working on a large web application which is primarily driven by JavaScript on client side. I am still in prototyping phase and I am at a point where source files become very long and I would like to split it up into multiple files.

For example in PHP I would just call include('source.php') or require_once('source.php').

Is there a similar way to connect multiple source files in JavaScript? There are many large web applications with intense use of JavaScript out there, what is the common solution?


Solution

  • RequireJS is a popular solution to this requirement.