metadata Posted August 8, 2012 Share Posted August 8, 2012 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 More sharing options...
birbal Posted August 8, 2012 Share Posted August 8, 2012 (edited) 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 August 8, 2012 by birbal Link to comment Share on other sites More sharing options...
thescientist Posted August 8, 2012 Share Posted August 8, 2012 of note, ASP is a server side language like PHP, not a client side language like Javascript. Link to comment Share on other sites More sharing options...
metadata Posted August 8, 2012 Author Share Posted August 8, 2012 OK, I just used asp as an example in terms of the #include functionality. Thanks for the replies Link to comment Share on other sites More sharing options...
justsomeguy Posted August 8, 2012 Share Posted August 8, 2012 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. Link to comment Share on other sites More sharing options...
metadata Posted August 8, 2012 Author Share Posted August 8, 2012 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 More sharing options...
justsomeguy Posted August 8, 2012 Share Posted August 8, 2012 It's the last part here: http://www.w3schools.com/js/js_whereto.asp 1 Link to comment Share on other sites More sharing options...
metadata Posted August 8, 2012 Author Share Posted August 8, 2012 OK, thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now