-
Notifications
You must be signed in to change notification settings - Fork 1
Fnug Javascript Dependency Resolver
algesten edited this page Jun 8, 2011
·
4 revisions
Fnug is a dependency resolver of javascript files that does:
- Dependency resolution of strongly connected components using JSDoc @requires tags.
- Dependencies are calculated for both Javascript and CSS.
- On-the-fly compression of CSS using YUI CSS Compressor.
- On-the-fly compression of Javascript using Google Closure Compiler.
- Logical grouping of resources in bundles.
- Bundles can be distributed as standard java .jar-files.
- On-the-fly JSLint of javascript.
Imagine we have the following files:
*source1.js*
/**
* @requires source2.js
*/
function foo() {
bar();
}
window.onload = foo;
source2.js
/**
* @requires source2styles.css
*/
function bar() {
var hello = document.createElement('div');
hello.className='hellothere';
hello.innerHTML = 'Hello World!';
document.body.appendChild(hello);
}
source2styles.css
.hellothere {
background: #ff00cc;
color: #000000;
font-size: 12em;
}
To make it work, we would need to:
- Load css (doesn't have to be loaded first)
- Load source2.js BEFORE source1.js
- Load source1.js
This is where those nifty @requires tags comes in handy. This software helps resolving those and ensure that resources are loaded in the correct order.