Compress cookbook
When downloading many JS files, it will bring a lot of overhead. The server can use simple compression technology to link the files to a file.
Compression script
Use the following command to compress your program's Js script:
C:\workspace\Cookbook>js cookbook\scripts\build.js
My local running results:
Then check whether there is a production. js file under the cookbook folder.
Switch to production mode
Use the scripts tag of steal on the page and change it to steal. Production. js to switch the production mode, as shown below:
<script type='text/javascript' src='../steal/steal.production.js?cookbook'></script>
Reload and confirm
Refresh the page and load only two JS files: steal. Production. js and production. js. This is much better than loading 28 files in development mode.
Docized cookbook
The document is very important for the maintainability code, but it will increase the work of developers, so it is often ignored. Javascriptmvc integrates documentjs to reduce this workload.
Generate document
Use the following command to generate a document:
> js cookbook/scripts/docs.js
Note: Make sure that cookbook.html is not in the production environment before running the command.
Local running result:
View document
Open the cookbook/doc.html page and you will see the following content:
Write document
The generated application only has a small document. Open cookbook/cookbook. md. Its syntax is similar to javadoc, but it is quite different. You can learn more in documentjs's documentation.
Javascriptmvc tutorial directory