Can we include an external js file into another js file?

Discussion in 'JavaScript' started by mahmood, Jan 22, 2007.

  1. #1
    Can we include an external .js file inside another external js file?

    What do I mean? Lets say I have a file called test.html and I include the following code there:
    Now, can I include or enter my other .js files into mainScript.js file instead of listing them on test.html?
     
    mahmood, Jan 22, 2007 IP
  2. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yup, just in mainScript.js put the code...

    document.write("<script src='moreStuff.js' type='text/javascript'></script>");
    Code (markup):
     
    giraph, Jan 22, 2007 IP
    mahmood likes this.