Include is used to load and compress JavaScript files.
You can load files relative to your current file and compress all your application
files into one with no extra coding.
How to Use
Create an application
Create an application by running:
js jmvc\generate\app APP_NAME
Add to your page
In your HTML, right before the closing </body> tag add a script tag like:
<script src="include.js?APP_NAME,development" type="text/javascript">
</script>
The parameters after the include are the application name and the development mode.
You can also create a page that loads your app by running:
js jmvc\generate\page APP_NAME location\to\page.html
Include JavaScript files
In your application file at
'apps\APP_NAME.js', include the files you need
in your project.
include('../resources/', 'javascripts/myapplication');
Includes are performed relative to the including file.
Files are included last-in-first-out after the current file has been loaded and run.
Compress your application
Run
js apps\APP_NAME\compress.js
Run in proudction
Switch to the production mode by changing development to production:
<script src="include.js?APP_NAME,production" type="text/javascript">
</script>
Script Load Order
The load order for your scripts follows a consistent last-in first-out order across all browsers.
This is the same way the following document.write would work in IE, Firefox, or Safari:
document.write('')
An example helps illustrate this.
| Load Order |
File |
| 1 |
1.js |
| 2 |
3.js |
| 3 |
4.js |
| 4 |
2.js |
| 5 |
5.js |
| 6 |
6.js |