Jump to content

#including files in JS


Recommended Posts

I have a question about #includes in javascript. I currently have an html file with a header section that has my functions. Is there a way I can put all these functions in a separate html file and then include that file? I would like to reduce the clutter in the current file and move all my functions off to a different one, increasing modularity. I found things in the asp section on this but not JS. Thanks!

Link to post
Share on other sites

if you use php there is http://php.net/include for that. js has not anything like that "include" you can get seprate file using ajax or load different script using DOM methods but that is not suitable for that. you should move on to any server side solution.

Edited by birbal
Link to post
Share on other sites
It sounds like you should just put all of your Javascript code into an external Javascript file and then include that in your script tag rather than writing the code in the script tag.
Yes that is what I want to do, I will look into finding the info on this.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...