Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "loadjs", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "authors": [ |
# LoadJS Changelog | ||
## 1.0.4 - May 25, 2016 | ||
* Added support for ad blocked script failures | ||
## 1.0.3 - May 18, 2016 | ||
@@ -4,0 +8,0 @@ |
@@ -89,5 +89,5 @@ loadjs = (function () { | ||
s.onload = s.onerror = function(ev) { | ||
s.onload = s.onerror = s.onbeforeload = function(ev) { | ||
// execute callback | ||
callbackFn(path, ev.type); | ||
callbackFn(path, ev.type[0], ev.defaultPrevented); | ||
}; | ||
@@ -112,5 +112,12 @@ | ||
// define callback function | ||
fn = function(path, result) { | ||
fn = function(path, result, defaultPrevented) { | ||
// handle error | ||
if (result[0] == 'e') pathsNotFound.push(path); | ||
if (result == 'e') pathsNotFound.push(path); | ||
// handle beforeload event. If defaultPrevented then that means the load | ||
// will be blocked (ex. Ghostery/ABP on Safari) | ||
if (result == 'b') { | ||
if (defaultPrevented) pathsNotFound.push(path); | ||
else return; | ||
} | ||
@@ -117,0 +124,0 @@ numWaiting--; |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){function n(n,t){n=n.push?n:[n];var o,e,r,i,u=[],a=n.length,l=a;for(o=function(n,o){o.length&&u.push(n),l--,l||t(u)};a--;)e=n[a],r=f[e],r?o(e,r):(i=c[e]=c[e]||[],i.push(o))}function t(n,t){if(n){var o=c[n];if(f[n]=t,o)for(;o.length;)o[0](n,t),o.splice(0,1)}}function o(n,t){var o=document,e=o.createElement("script");e.src=n,e.onload=e.onerror=function(o){t(n,o.type)},o.head.appendChild(e)}function e(n,t){n=n.push?n:[n];var e,r=n.length,i=r,u=[];for(e=function(n,o){"e"==o[0]&&u.push(n),i--,i||t(u)};r--;)o(n[r],e)}function r(n,o,r,f){var c,a,l;if(o&&!o.call&&(c=o),a=c?r:o,l=c?f:r,c){if(c in u)throw new Error("LoadJS: Bundle already defined");u[c]=!0}e(n,function(n){n.length?(l||i)(n):(a||i)(),t(c,n)})}var i=function(){},u={},f={},c={};return r.ready=function(t,o,e){return n(t,function(n){n.length?(e||i)(n):(o||i)()}),r},r.done=function(n){t(n,[])},r}(); | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,o,r,f,u=[],a=n.length,l=a;for(t=function(n,t){t.length&&u.push(n),l--,l||e(u)};a--;)o=n[a],r=i[o],r?t(o,r):(f=c[o]=c[o]||[],f.push(t))}function e(n,e){if(n){var t=c[n];if(i[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e){var t=document,o=t.createElement("script");o.src=n,o.onload=o.onerror=o.onbeforeload=function(t){e(n,t.type[0],t.defaultPrevented)},t.head.appendChild(o)}function o(n,e){n=n.push?n:[n];var o,r=n.length,f=r,u=[];for(o=function(n,t,o){if("e"==t&&u.push(n),"b"==t){if(!o)return;u.push(n)}f--,f||e(u)};r--;)t(n[r],o)}function r(n,t,r,i){var c,a,l;if(t&&!t.call&&(c=t),a=c?r:t,l=c?i:r,c){if(c in u)throw new Error("LoadJS: Bundle already defined");u[c]=!0}o(n,function(n){n.length?(l||f)(n):(a||f)(),e(c,n)})}var f=function(){},u={},i={},c={};return r.ready=function(e,t,o){return n(e,function(n){n.length?(o||f)(n):(t||f)()}),r},r.done=function(n){e(n,[])},r}(); |
@@ -97,5 +97,5 @@ (function(root, factory) { | ||
s.onload = s.onerror = function(ev) { | ||
s.onload = s.onerror = s.onbeforeload = function(ev) { | ||
// execute callback | ||
callbackFn(path, ev.type); | ||
callbackFn(path, ev.type[0], ev.defaultPrevented); | ||
}; | ||
@@ -120,5 +120,12 @@ | ||
// define callback function | ||
fn = function(path, result) { | ||
fn = function(path, result, defaultPrevented) { | ||
// handle error | ||
if (result[0] == 'e') pathsNotFound.push(path); | ||
if (result == 'e') pathsNotFound.push(path); | ||
// handle beforeload event. If defaultPrevented then that means the load | ||
// will be blocked (ex. Ghostery/ABP on Safari) | ||
if (result == 'b') { | ||
if (defaultPrevented) pathsNotFound.push(path); | ||
else return; | ||
} | ||
@@ -125,0 +132,0 @@ numWaiting--; |
@@ -89,5 +89,5 @@ loadjs = (function () { | ||
s.onload = s.onerror = function(ev) { | ||
s.onload = s.onerror = s.onbeforeload = function(ev) { | ||
// execute callback | ||
callbackFn(path, ev.type); | ||
callbackFn(path, ev.type[0], ev.defaultPrevented); | ||
}; | ||
@@ -112,5 +112,12 @@ | ||
// define callback function | ||
fn = function(path, result) { | ||
fn = function(path, result, defaultPrevented) { | ||
// handle error | ||
if (result[0] == 'e') pathsNotFound.push(path); | ||
if (result == 'e') pathsNotFound.push(path); | ||
// handle beforeload event. If defaultPrevented then that means the load | ||
// will be blocked (ex. Ghostery/ABP on Safari) | ||
if (result == 'b') { | ||
if (defaultPrevented) pathsNotFound.push(path); | ||
else return; | ||
} | ||
@@ -117,0 +124,0 @@ numWaiting--; |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){function n(n,t){n=n.push?n:[n];var o,e,r,i,u=[],a=n.length,l=a;for(o=function(n,o){o.length&&u.push(n),l--,l||t(u)};a--;)e=n[a],r=f[e],r?o(e,r):(i=c[e]=c[e]||[],i.push(o))}function t(n,t){if(n){var o=c[n];if(f[n]=t,o)for(;o.length;)o[0](n,t),o.splice(0,1)}}function o(n,t){var o=document,e=o.createElement("script");e.src=n,e.onload=e.onerror=function(o){t(n,o.type)},o.head.appendChild(e)}function e(n,t){n=n.push?n:[n];var e,r=n.length,i=r,u=[];for(e=function(n,o){"e"==o[0]&&u.push(n),i--,i||t(u)};r--;)o(n[r],e)}function r(n,o,r,f){var c,a,l;if(o&&!o.call&&(c=o),a=c?r:o,l=c?f:r,c){if(c in u)throw new Error("LoadJS: Bundle already defined");u[c]=!0}e(n,function(n){n.length?(l||i)(n):(a||i)(),t(c,n)})}var i=function(){},u={},f={},c={};return r.ready=function(t,o,e){return n(t,function(n){n.length?(e||i)(n):(o||i)()}),r},r.done=function(n){t(n,[])},r}(); | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,o,r,f,u=[],a=n.length,l=a;for(t=function(n,t){t.length&&u.push(n),l--,l||e(u)};a--;)o=n[a],r=i[o],r?t(o,r):(f=c[o]=c[o]||[],f.push(t))}function e(n,e){if(n){var t=c[n];if(i[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e){var t=document,o=t.createElement("script");o.src=n,o.onload=o.onerror=o.onbeforeload=function(t){e(n,t.type[0],t.defaultPrevented)},t.head.appendChild(o)}function o(n,e){n=n.push?n:[n];var o,r=n.length,f=r,u=[];for(o=function(n,t,o){if("e"==t&&u.push(n),"b"==t){if(!o)return;u.push(n)}f--,f||e(u)};r--;)t(n[r],o)}function r(n,t,r,i){var c,a,l;if(t&&!t.call&&(c=t),a=c?r:t,l=c?i:r,c){if(c in u)throw new Error("LoadJS: Bundle already defined");u[c]=!0}o(n,function(n){n.length?(l||f)(n):(a||f)(),e(c,n)})}var f=function(){},u={},i={},c={};return r.ready=function(e,t,o){return n(e,function(n){n.length?(o||f)(n):(t||f)()}),r},r.done=function(n){e(n,[])},r}(); |
{ | ||
"name": "loadjs", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Tiny async loader for modern browsers", |
@@ -5,3 +5,3 @@ # LoadJS | ||
LoadJS is a tiny async loader for modern browsers (503 bytes). | ||
LoadJS is a tiny async loader for modern browsers (537 bytes). | ||
@@ -15,3 +15,3 @@ [![Dependency Status](https://david-dm.org/muicss/loadjs.svg)](https://david-dm.org/muicss/loadjs) | ||
LoadJS is based on the excellent <a href="https://github.com/ded/script.js">$script</a> library by <a href="https://github.com/ded">Dustin Diaz</a>. We kept the behavior of the library the same but we re-wrote the code from scratch to add support for success/failure callbacks and to optimize the library for modern browsers. LoadJS is 503 bytes (minified + gzipped). | ||
LoadJS is based on the excellent <a href="https://github.com/ded/script.js">$script</a> library by <a href="https://github.com/ded">Dustin Diaz</a>. We kept the behavior of the library the same but we re-wrote the code from scratch to add support for success/failure callbacks and to optimize the library for modern browsers. LoadJS is 537 bytes (minified + gzipped). | ||
@@ -60,2 +60,7 @@ Here's an example of what you can do with LoadJS: | ||
LoadJS also detects script failures from AdBlock Plus and Ghostery in: | ||
* Safari | ||
* Chrome | ||
## Documentation | ||
@@ -62,0 +67,0 @@ |
@@ -88,5 +88,5 @@ /** | ||
s.onload = s.onerror = function(ev) { | ||
s.onload = s.onerror = s.onbeforeload = function(ev) { | ||
// execute callback | ||
callbackFn(path, ev.type); | ||
callbackFn(path, ev.type[0], ev.defaultPrevented); | ||
}; | ||
@@ -111,5 +111,12 @@ | ||
// define callback function | ||
fn = function(path, result) { | ||
fn = function(path, result, defaultPrevented) { | ||
// handle error | ||
if (result[0] == 'e') pathsNotFound.push(path); | ||
if (result == 'e') pathsNotFound.push(path); | ||
// handle beforeload event. If defaultPrevented then that means the load | ||
// will be blocked (ex. Ghostery/ABP on Safari) | ||
if (result == 'b') { | ||
if (defaultPrevented) pathsNotFound.push(path); | ||
else return; | ||
} | ||
@@ -116,0 +123,0 @@ numWaiting--; |
@@ -89,5 +89,5 @@ loadjs = (function () { | ||
s.onload = s.onerror = function(ev) { | ||
s.onload = s.onerror = s.onbeforeload = function(ev) { | ||
// execute callback | ||
callbackFn(path, ev.type); | ||
callbackFn(path, ev.type[0], ev.defaultPrevented); | ||
}; | ||
@@ -112,5 +112,12 @@ | ||
// define callback function | ||
fn = function(path, result) { | ||
fn = function(path, result, defaultPrevented) { | ||
// handle error | ||
if (result[0] == 'e') pathsNotFound.push(path); | ||
if (result == 'e') pathsNotFound.push(path); | ||
// handle beforeload event. If defaultPrevented then that means the load | ||
// will be blocked (ex. Ghostery/ABP on Safari) | ||
if (result == 'b') { | ||
if (defaultPrevented) pathsNotFound.push(path); | ||
else return; | ||
} | ||
@@ -117,0 +124,0 @@ numWaiting--; |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){function n(n,t){n=n.push?n:[n];var o,e,r,i,u=[],a=n.length,l=a;for(o=function(n,o){o.length&&u.push(n),l--,l||t(u)};a--;)e=n[a],r=f[e],r?o(e,r):(i=c[e]=c[e]||[],i.push(o))}function t(n,t){if(n){var o=c[n];if(f[n]=t,o)for(;o.length;)o[0](n,t),o.splice(0,1)}}function o(n,t){var o=document,e=o.createElement("script");e.src=n,e.onload=e.onerror=function(o){t(n,o.type)},o.head.appendChild(e)}function e(n,t){n=n.push?n:[n];var e,r=n.length,i=r,u=[];for(e=function(n,o){"e"==o[0]&&u.push(n),i--,i||t(u)};r--;)o(n[r],e)}function r(n,o,r,f){var c,a,l;if(o&&!o.call&&(c=o),a=c?r:o,l=c?f:r,c){if(c in u)throw new Error("LoadJS: Bundle already defined");u[c]=!0}e(n,function(n){n.length?(l||i)(n):(a||i)(),t(c,n)})}var i=function(){},u={},f={},c={};return r.ready=function(t,o,e){return n(t,function(n){n.length?(e||i)(n):(o||i)()}),r},r.done=function(n){t(n,[])},r}(); | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,o,r,f,u=[],a=n.length,l=a;for(t=function(n,t){t.length&&u.push(n),l--,l||e(u)};a--;)o=n[a],r=i[o],r?t(o,r):(f=c[o]=c[o]||[],f.push(t))}function e(n,e){if(n){var t=c[n];if(i[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e){var t=document,o=t.createElement("script");o.src=n,o.onload=o.onerror=o.onbeforeload=function(t){e(n,t.type[0],t.defaultPrevented)},t.head.appendChild(o)}function o(n,e){n=n.push?n:[n];var o,r=n.length,f=r,u=[];for(o=function(n,t,o){if("e"==t&&u.push(n),"b"==t){if(!o)return;u.push(n)}f--,f||e(u)};r--;)t(n[r],o)}function r(n,t,r,i){var c,a,l;if(t&&!t.call&&(c=t),a=c?r:t,l=c?i:r,c){if(c in u)throw new Error("LoadJS: Bundle already defined");u[c]=!0}o(n,function(n){n.length?(l||f)(n):(a||f)(),e(c,n)})}var f=function(){},u={},i={},c={};return r.ready=function(e,t,o){return n(e,function(n){n.length?(o||f)(n):(t||f)()}),r},r.done=function(n){e(n,[])},r}(); |
@@ -186,2 +186,22 @@ /** | ||
}); | ||
// Un-'x' this for testing ad blocked scripts. | ||
// Ghostery: Disallow "Google Adservices" | ||
// AdBlock Plus: Add "www.googletagservices.com/tag/js/gpt.js" as a | ||
// custom filter under Options | ||
// | ||
xit('it should report ad blocked scripts as missing', function(done) { | ||
var blockedScript = 'https://www.googletagservices.com/tag/js/gpt.js'; | ||
loadjs([blockedScript, 'assets/file1.js'], | ||
function() { | ||
throw "Executed success callback"; | ||
}, | ||
function(pathsNotFound) { | ||
assert.equal(pathsLoaded['file1.js'], true); | ||
assert.equal(pathsNotFound.length, 1); | ||
assert.equal(pathsNotFound[0], blockedScript); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
333821
11428
226