Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use Grunt to build minified script #35

Merged
merged 1 commit into from

2 participants

@gmarty

No description provided.

@vvo vvo merged commit b639b5e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 28, 2013
  1. @gmarty
This page is out of date. Refresh to see the latest.
Showing with 45 additions and 3 deletions.
  1. +2 −1  .gitignore
  2. +39 −0 Gruntfile.js
  3. +1 −1  lazyload.min.js
  4. +3 −1 package.json
View
3  .gitignore
@@ -1 +1,2 @@
-node_modules
+node_modules
+*.report.txt
View
39 Gruntfile.js
@@ -0,0 +1,39 @@
+module.exports = function(grunt) {
+
+ grunt.loadNpmTasks('grunt-closure-compiler');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+
+ // Project configuration.
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+
+ 'closure-compiler': {
+ min: {
+ js: 'lazyload.js',
+ jsOutputFile: 'lazyload.min.js',
+ options: {
+ compilation_level: 'ADVANCED_OPTIMIZATIONS',
+ //language_in: 'ECMASCRIPT5_STRICT',
+ summary_detail_level: 3,
+ warning_level: 'VERBOSE',
+ debug: false,
+ output_wrapper: '"(function(){%output%})();"'
+ }
+ }
+ },
+
+ concat: {
+ options: {
+ banner: '/*! <%= pkg.name %> v<%= pkg.version %> | github.com/vvo/lazyload#licence */\n'
+ },
+ dist: {
+ src: ['lazyload.min.js'],
+ dest: 'lazyload.min.js'
+ }
+ }
+ });
+
+ // Default task.
+ grunt.registerTask('default', ['closure-compiler', 'concat']);
+
+};
View
2  lazyload.min.js
@@ -6,4 +6,4 @@ m(this.k,this);"HTMLImageElement"in j&&this.l()},m=function(a,b){return function
d});h=r.prototype;h.l=function(){var a=HTMLImageElement.prototype.getAttribute,b=this;HTMLImageElement.prototype.getAttribute=function(c){return"src"===c?a.call(this,b.a.n)||a.call(this,c):a.call(this,c)}};h.f=function(){this.a.container=k.body};h.k=function(a){this.a.container===k&&this.f();null!==a.getAttribute(this.a.lazyAttr)&&-1===v.call(this.b,a)&&(this.d||this.i(),this.g(a,this.b.push(a)-1))};h.j=function(){for(var a=k.getElementsByTagName("img"),b,c=0,f=a.length;c<f;c+=1)b=a[c],b.getAttribute(this.a.lazyAttr)&&
-1===v.call(this.b,b)&&this.b.push(b)};h.g=function(a,b){var c;if(c=w(k.documentElement,a)){c=this.a.container;var f=this.a.offset;f||(f=Math.max(a.clientHeight,a.clientWidth));var e=a.getBoundingClientRect(),l=e.left-f,f=e.top-f,p=e=0;c===k.body?(e+=k.documentElement.clientWidth,p+=k.documentElement.clientHeight):(l+=s().x,f+=s().y,e+=c.clientWidth,p+=c.clientHeight);c=f<=p&&l<=e}return c?(a.onload=null,a.removeAttribute("onload"),a.onerror=null,a.removeAttribute("onerror"),a.src=a.getAttribute(this.a.lazyAttr),
a.removeAttribute(this.a.lazyAttr),this.b[b]=null,d):g};h.h=function(){var a=this.b.length,b,c=d;for(b=0;b<a;b++){var f=this.b[b];null!==f&&!this.g(f,b)&&(c=g)}c&&t&&this.m()};h.m=function(){var a=this.e,b=this.c;a.detachEvent?a.detachEvent&&a.detachEvent("onscroll",b):a.removeEventListener("scroll",b,g);this.d=g;this.b=[]};h.i=function(){q(this.e,"scroll",this.c);this.d=d};var w=k.documentElement.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.documentElement.contains?
-function(a,b){return a!==b&&(a.contains?a.contains(b):g)}:function(a,b){for(;b=b.parentNode;)if(b===a)return d;return g},v=[].indexOf||function(a){for(var b=this.length;b--&&this[b]!==a;);return b}};})();
View
4 package.json
@@ -8,7 +8,9 @@
},
"dependencies": {
"wd": "0.0.x",
- "async": "0.1.x"
+ "async": "0.1.x",
+ "grunt-closure-compiler": "0.0.x",
+ "grunt-contrib-concat": "0.1.x"
},
"private": true,
"keywords": [
Something went wrong with that request. Please try again.