简体   繁体   中英

How do I split up long JS code into seperate files as an object?

Say I have a file.js with a lot of functions and code, which I want to seperate into different files.

What would be a best-practice structure to do this? And I think that I'm talking about creating an object. But I'm not sure..

Thanks in advance,

Nick

JavaScript does not have a simple method of including other JavaScript files. Generally I create several files and include them individually for testing. For production I use ant to concatenate the files and apply something like the closure-compiler and/or yui compressor on the output. Something like this may serve as a good starting point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM