Permalink
Browse files

Shave some bytes, then add them back by using a more reliable (but lo…

…nger) isArray check.
  • Loading branch information...
1 parent f930111 commit 0fa136295b95818dbf972c3f3df985ce9bc70b88 @rgrove committed Nov 28, 2010
Showing with 24 additions and 25 deletions.
  1. +1 −1 README.md
  2. +4 −4 lazyload-min.js
  3. +19 −20 lazyload.js
View
@@ -1,7 +1,7 @@
LazyLoad
========
-LazyLoad is a tiny (only 989 bytes minified and gzipped), dependency-free
+LazyLoad is a tiny (only 998 bytes minified and gzipped), dependency-free
JavaScript library that makes it super easy to load external JavaScript and CSS
files on demand. It's ideal for quickly and unobtrusively loading large external
scripts and stylesheets either lazily after the rest of the page has finished
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -108,27 +108,25 @@ LazyLoad = (function () {
callback,
urls;
- if (!p) {
- return;
- }
-
- callback = p.callback;
- urls = p.urls;
-
- urls.shift();
- pollCount = 0;
-
- // If this is the last of the pending URLs, execute the callback and
- // start the next request in the queue (if any).
- if (!urls.length) {
- if (callback) {
- callback.call(p.context || window, p.obj);
- }
+ if (p) {
+ callback = p.callback;
+ urls = p.urls;
+
+ urls.shift();
+ pollCount = 0;
+
+ // If this is the last of the pending URLs, execute the callback and
+ // start the next request in the queue (if any).
+ if (!urls.length) {
+ if (callback) {
+ callback.call(p.context, p.obj);
+ }
- pending[type] = null;
+ pending[type] = null;
- if (queue[type].length) {
- load(type);
+ if (queue[type].length) {
+ load(type);
+ }
}
}
}
@@ -219,7 +217,8 @@ LazyLoad = (function () {
if (urls) {
// Cast urls to an Array.
- urls = urls.constructor === Array ? urls : [urls];
+ urls = Object.prototype.toString.call(urls) === '[object Array]' ?
+ urls : [urls];
// Create a request object for each URL. If multiple URLs are specified,
// the callback will only be executed after all URLs have been loaded.

0 comments on commit 0fa1362

Please sign in to comment.