Jump to content

#including files in JS


metadata

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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...