Skip to content

Instantly share code, notes, and snippets.

@nqthqn
Last active May 23, 2017 04:31
Show Gist options
  • Save nqthqn/36d8603d5481c6ae63908aeb3a266470 to your computer and use it in GitHub Desktop.
Save nqthqn/36d8603d5481c6ae63908aeb3a266470 to your computer and use it in GitHub Desktop.
Obtain better load time!
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