cbodapati Posted June 26, 2014 Share Posted June 26, 2014 Hi,Iam new to js programming.I have some js code in 1 big file (2300 lines) and expecting to grow.I want to break it into 3-5 files. like separate the base types and instances.I want to know, if a base type is in base.js, then how do I include in a derived.js where I want to create an instance of what is declared in base.jsany help appreciated.thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted June 30, 2014 Share Posted June 30, 2014 You're talking about dependency injection.https://www.google.com/search?client=opera&q=javascript+dependency+injection&sourceid=opera&ie=UTF-8&oe=UTF-8 Link to comment Share on other sites More sharing options...
thescientist Posted July 7, 2014 Share Posted July 7, 2014 you might want to look into something like require.js. Ideally though, you do want all your JS in as few files as possible. One option is to use a build tool like Grunt to concatenate (and ideally minify) your script files at build time. So locally you get the full, developer friendly versions of the files, but then only include the single file for use in production. Link to comment Share on other sites More sharing options...
cbodapati Posted July 15, 2014 Author Share Posted July 15, 2014 thanks for the replies guys. Those were useful. 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