Skip to content

Fnug Javascript Dependency Resolver

algesten edited this page Nov 24, 2010 · 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.

Example

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:

  1. Load css
  2. Load source2.js BEFORE source1.js
  3. 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.

Clone this wiki locally