lockandload
Advanced tools
Comparing version 1.2.6 to 2.0.13
@@ -1,11 +0,18 @@ | ||
!function(W,D,A,T,e,t) | ||
!function(W,D,E,A,T,P,e,t) | ||
{ "use strict"; | ||
function n(u,e,a,v,r,p,k) | ||
{ k=D.createElement(e); k[a]=v; k[r]=u; D.head.appendChild(k); | ||
if(p) k.onload=function() { define(p, 1); }; } | ||
if(p) k.onload=function() { E(p, 1); }; } | ||
function css(u,p) { n(u,"link","rel","stylesheet","href",p); } | ||
function js(u,a) { n(u,"script",A,a,"src"); } | ||
function jsa(a,p) { P[a]=p; } | ||
/* | ||
** This is your config area. Customise to taste. | ||
** | ||
** Define a bunch of pathname aliases to reference javascript files that | ||
** shall be loaded through require.load(path) on demand. | ||
** Specifying those here now avoids sprinkling pathnames throughout | ||
** your other modules' source code: | ||
**jsa("lzstring", "js/lz-string.js"); | ||
** | ||
** Optional headready define, if you want it, uncomment the next line: | ||
@@ -64,2 +71,12 @@ **define("headready", 1); | ||
}); | ||
}(window,document,"async",setTimeout); | ||
E("require", ["module"], function(R) | ||
{ function r(d,f) { return f ? E(1,d,f) : R[d]; } | ||
r.undef=function(n){ R[n]=0; }; r.load=function(p){ js(P[p]||p, A); }; | ||
return r; }); | ||
W.onload=function(){ E("domready", ["module"], function(R) | ||
{ return function(t,i) | ||
{ if(E.S[0]||t==1) | ||
{ while (i=E.Q.shift()) i(); | ||
t=!(t==1?E.S.shift():t)&&R.jquery?$(D):t; | ||
for (i=0; i<E.S.length; E.S[i++](t)); } }; }); }; | ||
}(window,document,define,"async",setTimeout,{}); |
@@ -1,13 +0,17 @@ | ||
// License: ISC OR GPL-3.0 | ||
!function(W,D,U,X,M,S,Q,L,R) // lockandload v1.2: boilerplate AMD-loader | ||
{ "use strict"; // Copyright (c) 2018 <srb@cuci.nl> | ||
W.dataLayer=[{"gtm.start":Date.now(),event:"gtm.js"}]; | ||
function e(n,d,f) | ||
{ var i,j,t,u=[],k=0; | ||
function c(m) | ||
{ if (u[d.indexOf(m)]=R[m], ++k>=j) | ||
{ j=L[n]||[]; delete L[n]; R[X]=R[n]; | ||
R[n]=(typeof f=="function"?f.apply(0,u):f)||R[X]; | ||
while (f=j.pop()) f(n); | ||
} | ||
// License: ISC OR GPL-3.0 | ||
!function(W,D,X,M,L,R) // lockandload v2.0: boilerplate AMD-loader | ||
{ "use strict"; // Copyright (c) 2018 <srb@cuci.nl> | ||
W.dataLayer=[{"gtm.start":Date.now(),event:"gtm.js"}]; R[M]=R; | ||
function E(n,d,f,j) | ||
{ function c(k,i,t) | ||
{ for (i in k) | ||
{ if ((t=k[i])==X||t==M) R[n]=R[X]; | ||
j+=(!(t in R)&&(L[t]||(L[t]=[])).push(c)); | ||
} | ||
if (!--j) | ||
{ R[X]=R[n]; for (t in d) d[t]=R[d[t]]; | ||
R[n]=(typeof f=="function"?f.apply(0,d):f)||R[X]; | ||
d=L[n]||[]; delete L[n]; | ||
while (f=d.pop()) f(); | ||
} | ||
} | ||
@@ -20,19 +24,7 @@ if (!f) if (f=d, d=0, !f) f=n, n=0; else if (Array.isArray(n)) d=n, n=0; | ||
} | ||
d||(d=[U,X,M]).splice(f.length); | ||
if (j=i=d.length) | ||
for (R[X]={}; i--; ) | ||
{ if ((t=d[i])==X||t==M) R[n]=R[X]; | ||
if (t in R) c(t); else if (L[t]) L[t].push(c); else L[t]=[c]; | ||
} | ||
else c(); | ||
j=1; R[X]={}; c(d=d||["require",X,M].splice(0,f.length||0)); | ||
} | ||
function E(d,f) { return f ? e(1,d,f) : R[d]; } | ||
(R[M]=R)[U]=E; | ||
(W.define=e).amd={lockandload:E||"v1.1, Copyright (c) 2018 <srb@cuci.nl>"}; | ||
W.$$=function(f) { S.push(f); }; W.$=function(f) { Q.push(f); }; | ||
W.onload=function(){ e("domready", function() { return function(t,i) | ||
{ if(S[0]||t==1) | ||
{ while (i=Q.shift()) i(); | ||
t=!(t==1?S.shift():t)&&R.jquery?$(D):t; | ||
for (i=0; i<S.length; S[i++](t)); } }; }); }; | ||
}(window,document,"require","exports","module",[0],[],{},{}); | ||
(W.define=E).amd={lockandload:E||"v2.0, Copyright (c) 2018 <srb@cuci.nl>"}; | ||
E.S=[0]; W.$$=function(f){ E.S.push(f); }; | ||
E.Q=[]; W.$=function(f){ E.Q.push(f); }; | ||
}(window,document,"exports","module",{},{}); |
{ | ||
"name": "lockandload", | ||
"version": "1.2.6", | ||
"version": "2.0.13", | ||
"description": "Minimalist AMD-compliant Javascript and CSS loader", | ||
@@ -5,0 +5,0 @@ "main": "index.html", |
@@ -6,10 +6,10 @@ <h1>lockandload AMD-loader</h1> | ||
Gzipped, the essential script content amounts to roughly 1KB of code. | ||
Without compression it blows up to just under 2KB. Further minifying this | ||
code does not result in any significant gains, it would just hinder | ||
readability. | ||
Gzipped, the essential script content amounts to roughly 859 bytes of code. | ||
Without compression it blows up to about 1520 bytes. Further minifying | ||
this code does not result in any significant gains (773 vs 859 bytes), it | ||
would just hinder readability. | ||
## Features | ||
- Less filling: 1KB of gzipped script content. | ||
- Less filling: 859 bytes of gzipped script content. | ||
- Handminified to retain readable and maintainable code. | ||
@@ -22,2 +22,4 @@ - It's so small, it can and should be inlined on your HTML page | ||
- Supports local require() calls (with one and two arguments, RequireJS-style). | ||
- Supports require.undef() for hot-reloading scripts. | ||
- Supports require.load() to load scripts on demand. | ||
- Supports implicit and explicit ['require', 'exports', 'module'] dependencies. | ||
@@ -64,2 +66,6 @@ - Explicit circular dependencies will silently hang in unresolved state | ||
- `index.php`: PHP boilerplate. | ||
- `index_inlined.html`: High performance HTML only boilerplate. | ||
- `lockandload_master.js`: For lazy `<script>` loading. | ||
- `lockandload_headready.js`: Boilerplate for lazy `<script>` loading. | ||
- `index_extern.html`: Lazy HTML only boilerplate. | ||
- `main.js`: Example SPA (Single Page Application). | ||
@@ -77,7 +83,7 @@ | ||
### Without serverside scripting easy | ||
### Without serverside scripting (lazy) | ||
Copy the `node_modules/lockandload/index_extern.html` boilerplate | ||
file to your webroot; then customise the copied file to taste. | ||
Copy the `node_modules/lockandload/lockandload_headready.html` file | ||
Copy the `node_modules/lockandload/lockandload_headready.js` file | ||
to your javascript directory and customise it taste. Do not forget | ||
@@ -87,3 +93,3 @@ to change the path of the `script` directive in `index_extern.html` | ||
### Without serverside scripting high performance | ||
### Without serverside scripting (high performance) | ||
@@ -154,2 +160,5 @@ Copy the `node_modules/lockandload/index_inlined.html` boilerplate | ||
provided, the load will be asynchronous. | ||
- `jsa(alias, path)`<br /> | ||
Define aliases for javacsript file paths to be referenced through | ||
`require.load(alias)` to load the file on demand. | ||
@@ -211,9 +220,6 @@ ### Dealing with jQuery | ||
(AMD)](https://github.com/amdjs/amdjs-api/blob/master/AMD.md). | ||
- Inspired by [Curiosity-Driven's minimal | ||
loader](https://curiosity-driven.org/minimal-loader): | ||
reducing the featureset of lockandload to that what that loader supports, | ||
we end up with 320 bytes for reduced-lockandload and 386 bytes for | ||
that loader. | ||
Other loaders: | ||
- [eeMD](https://github.com/MaxMotovilov/eeMD). | ||
- [Curiosity-Driven](https://curiosity-driven.org/minimal-loader). | ||
- [RequireJS](https://requirejs.org/). | ||
@@ -223,1 +229,9 @@ - [curl](https://github.com/cujojs/curl). | ||
- [lsjs](https://github.com/zazl/lsjs). | ||
- [amdlite](https://github.com/abadc0de/amdlite). | ||
- [tinyamd](https://github.com/briancray/tinyamd). | ||
- [tAMD](https://github.com/jivesoftware/tAMD). | ||
- [almond](https://github.com/requirejs/almond). | ||
- [bdLoad](http://bdframework.org/bdLoad/). | ||
- [yabble](https://github.com/jbrantly/yabble). | ||
- [PINF](https://github.com/pinf/loader-js). | ||
- [nodules](https://github.com/kriszyp/nodules). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
37257
117
230