Last active
May 23, 2017 04:31
-
-
Save nqthqn/36d8603d5481c6ae63908aeb3a266470 to your computer and use it in GitHub Desktop.
Obtain better load time!
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
var tinify = require("tinify"); | |
var walk = require('walk'); | |
tinify.key = "your key"; | |
var files = []; | |
var walker = walk.walk('./images', { followLinks: false }); | |
walker.on('file', function(root, stat, next) { | |
files.push(root + '/' + stat.name); | |
next(); | |
}); | |
walker.on('end', function() { | |
files.map(function(file){ | |
tinify.fromFile(file).toFile(file); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment