node package manager


Simple script loader and compiler

HarvestJS (working)

Simple script loader and compiler

  • Multiple script loader
  • Compiler to concat and minify scritps

This will load "js/main.js" when DOM is ready.

<script src="vendors/harvest.js" 
  • data-path : The path to script's root directory
    (If ommitted, set as the path where harvest.js is saved)
  • data-main : Start loading the scripts when DOM is ready
    (comma/space separated string for multiple sources)

You may use harvest() function to load sub-resources in "init.js" or "main.js"

// main.js 

These paths should be relative to script's root directory (data-path).

If you pass function as last argument, the callback will be called when all script is loaded.

        // do something 

But compiler doesn't support unifying the script with callback.

Compiler as grunt task will help you to concat or minify scripts.

// or  
// grunt.loadTasks("the/path/to/harvestjs/tasks"); 
    harvest: {
        options: {
            path: "js/",
            banner: "/* <%='yyyy-mm-dd') %> */",
            uglify: {}
        dist: {
            files: {
                "js/main.unified.js": "js/main.js"
  • path:String ("") = The script root path
  • banner:String ("") = Banner string to be prepended to unified script
  • uglify:Object ({}) = UglifyJS2's compress options (Pass false not to minify script)