Justin Meyer has been working on a JavaScript library named IncludeJS and has released a 0.1 alpha 1 Developer package. IncludeJS lets developers include and compress JavaScript files easily. The hope for the library is "to bridge the gap between frameworks like jQuery/Prototype which guess at what you will most likely need, and frameworks like MooTools, which are great if you know exactly what you want and don't need to look in the source."
IncludeJS was originally a component of JavaScriptMVC - an open source JavaScript Model-View-Controller framework. The framework is going through some major changes and individual components are being extracted to make each individually useful.
Features of IncludeJS:
Relative paths.
Instead of including files relative to the current page's url,
IncludeJS includes files relative to your JavaScript files' urls.
Forget about scanning the page's script tags for your library's path.
IncludeJS lets you organize your scripts however you want.Dynamic compression.
IncludeJS uses Dean Edwards packer
to automatically compress your
JavaScripts. Unlike server-side compression scripts,
compression is determined at runtime. This makes
it easy to compress large libraries with optional plugins.Highlights.
- Consistant include order (last-in-first-out)
- FF 1.5+, IE 6+, Opera 9, Safari 3.
- Works with libraries like Prototype and jQuery.
- MIT license.
- 3 KB compressed.
- Files visible in Firebug.
Usage
1) Include the library in your page
<script src="include.js" type="text/javascript"
script>
2) Include JavaScript files with the include function, files are relative to the including file and will be included in LIFO [last-in-first-out] order.
<script type="text/javascript">
include( 'javascripts/prototype',
'javascripts/myapplication'
)
script>
3) Compress your app by adding the line:
include.setup('compress')
before your includes, after the page loads you're presented with a compressed version of the code.
<script type="text/javascript">
include.setup('compress')
include( 'javascripts/prototype',
'javascripts/myapplication'
)
script
4) Run it! After you've saved the compressed version of the code, change the "compress" argument to "production" and specify the path to the newly created library as a second argument.
<script type="text/javascript">
include.setup('production','path/to/prod')
include( 'javascripts/prototype',
'javascripts/myapplication'
)
script
Nema komentara:
Objavi komentar