Created
August 15, 2012 07:33
-
-
Save anton-ryzhov/3357389 to your computer and use it in GitHub Desktop.
js include / make
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="js/main.js" id="script_include" type="text/javascript"></script> | |
=> | |
<script src="js/main.js" id="script_include" type="text/javascript"></script> | |
<script src="js/less-1.3.0.js" type="text/javascript"></script> | |
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script> | |
<script src="js/jquery-ui.js" type="text/javascript"></script> | |
user@domain:~/js$ node main.js > out | |
== | |
user@domain:~/js$ cat less-1.3.0.js jquery-1.7.2.min.js jquery-ui.js > out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(include) { | |
var prefix, fs, i; | |
// Import JS in-place into document | |
if ((typeof document != 'undefined') && document.write && document.getElementById && (prefix = document.getElementById('script_include'))) | |
{ | |
prefix = prefix.src.replace(/[\w\.-]+$/, ''); // Get URI prefix | |
for (i in include) | |
document.write('<script src="' + prefix + include[i] + '" type="text/javascript"></script>'); | |
} | |
// Write to stdout if node.js | |
if (typeof require == 'function') | |
{ | |
fs = require('fs'); | |
for (i in include) | |
process.stdout.write(fs.readFileSync(include[i])); | |
} | |
})(['less-1.3.0.js', 'jquery-1.7.2.min.js', 'jquery-ui.js']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment