diff --git a/Gruntfile.js b/Gruntfile.js index 478b42c..1aa5b89 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,11 +8,52 @@ module.exports = function(grunt) { banner: '/*! Cache API Key/Value Store v<%= pkg.version %>\n * (c) https://github.com/optimalisatie */\n' }, + // minify + uglify: { + + "cache-api-keyval": { + options: { + compress: { + global_defs: { + "SILENT": false + } + }, + mangle: {}, + dead_code: true, + banner: '' + }, + files: { + 'min/cache-api-keyval.js': [ + 'src/cache-api-keyval.js' + ] + } + }, + + "cache-api-keyval-silent": { + options: { + compress: { + global_defs: { + "SILENT": true + } + }, + mangle: {}, + dead_code: true, + banner: '' + }, + files: { + 'min/cache-api-keyval.silent.js': [ + 'src/cache-api-keyval.js' + ] + } + } + + }, + // closure compiler "closure-compiler": { "cache-api-keyval": { closurePath: 'closure-compiler', - js: 'src/cache-api-keyval.js', + js: 'min/cache-api-keyval.js', jsOutputFile: 'dist/cache-api-keyval.js', maxBuffer: 10000, options: { @@ -21,6 +62,19 @@ module.exports = function(grunt) { externs: ['cache-api-keyval.ext.js'], define: ['DEBUG=false'] } + }, + + "cache-api-keyval-silent": { + closurePath: 'closure-compiler', + js: 'min/cache-api-keyval.silent.js', + jsOutputFile: 'dist/cache-api-keyval.silent.js', + maxBuffer: 10000, + options: { + compilation_level: 'ADVANCED_OPTIMIZATIONS', + language_in: 'ECMASCRIPT5_STRICT', + externs: ['cache-api-keyval.ext.js'], + define: ['DEBUG=false'] + } } } }); @@ -29,7 +83,8 @@ module.exports = function(grunt) { require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); grunt.registerTask('build', [ - 'closure-compiler:cache-api-keyval' + 'uglify', + 'closure-compiler' ]); grunt.registerTask('default', ['']); }; \ No newline at end of file diff --git a/README.md b/README.md index fbf96eb..6481fed 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,22 @@ window.CacheApiDBFallback = function(store, options) { this.del = function(key) { /* delete key from store */ } this.prune = function() { /* cleanup database */ } }; -``` \ No newline at end of file +``` + +## Tinier + +`cache-api-keyval.silent.js` is a stripped version without error reporting and fallback mechanism. It can be used with manual Cache API verification. + + +```html + +