Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lockandload

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lockandload - npm Package Compare versions

Comparing version 2.0.13 to 2.1.4

.jshintrc

37

lockandload_headready.js

@@ -1,11 +0,11 @@

!function(W,D,E,A,T,P,e,t)
!function(W,D,E,P)
{ "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() { 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; }
function n(e,a,v,r,u,p,k)
{ k=D.createElement(e); if(p) k.onload=function(){ E(p, 1); };
if (a) k[a]=v; k[r]=u; D.head.appendChild(k); }
function css(u,p){ n("link","rel","stylesheet","href",u,p); }
function js(u,a){ n("script",a,a,"src",u); }
function jsa(a,p){ P[a]=p; }
/*
** This is your config area. Customise to taste.
** This is the start of your config area. Customise to taste.
**

@@ -27,3 +27,3 @@ ** Define a bunch of pathname aliases to reference javascript files that

**
**t="//cdn.remixml.org/css/";
**var t="//cdn.remixml.org/css/";
**css(t+"blue.css", "bluecssloaded"); // CSS fulfilling dependency

@@ -35,3 +35,3 @@ **css(t+"sample.css"); // Low prio CSS

**
**define(1, ["domready"], function() {
**require(["domready"], function() {
** js("//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js");

@@ -46,4 +46,4 @@ **});

*/
define(1, ["domready", "jquery"], function(domready) {
/*t="//cdn.remixml.org/js/";
require(["domready", "jquery"], function(domready) {
/*var t="//cdn.remixml.org/js/";
**js(t+"sequentialload.js"); // Legacy sequential low prio loads

@@ -56,3 +56,3 @@ **js(t+"sequentialload2.js"); // Legacy sequential low prio loads

*/
T(function() {
setTimeout(function() {
/*

@@ -75,6 +75,9 @@ ** Low priority non-interactive

});
/*
** This is where your config area ends. Do not edit until after the
** end of the script
*/
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; });
{ 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, "async"); }; return r; });
W.onload=function(){ E("domready", ["module"], function(R)

@@ -86,2 +89,2 @@ { return function(t,i)

for (i=0; i<E.S.length; E.S[i++](t)); } }; }); };
}(window,document,define,"async",setTimeout,{});
}(window,document,define,{});

@@ -1,4 +0,4 @@

// 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>
// License: ISC OR GPL-3.0
!function(W,D,F,X,M,L,R) // lockandload v2.1: boilerplate AMD-loader
{ "use strict"; // Copyright (c) 2018 <srb@cuci.nl>
W.dataLayer=[{"gtm.start":Date.now(),event:"gtm.js"}]; R[M]=R;

@@ -8,4 +8,4 @@ function E(n,d,f,j)

{ 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 ((t=k[i])==X||t==M) R[n]=R[X], L[n]=L[n]||[Date];
j+=(!(R[t]&&!L[t])&&(L[t]||(L[t]=[])).push(c));
}

@@ -25,7 +25,8 @@ if (!--j)

}
j=1; R[X]={}; c(d=d||["require",X,M].splice(0,f.length||0));
R[j=1]=0; R[X]={}; c(d=d||[F,X,M]);
}
(W.define=E).amd={lockandload:E||"v2.0, Copyright (c) 2018 <srb@cuci.nl>"};
(W.define=E).amd={lockandload:E||"v2.1, Copyright (c) 2018 <srb@cuci.nl>"};
W[F]=function(d,f){ E(1,d,f); };
E.S=[0]; W.$$=function(f){ E.S.push(f); };
E.Q=[]; W.$=function(f){ E.Q.push(f); };
}(window,document,"exports","module",{},{});
}(window,document,"require","exports","module",{},{});
{
"name": "lockandload",
"version": "2.0.13",
"version": "2.1.4",
"description": "Minimalist AMD-compliant Javascript and CSS loader",

@@ -5,0 +5,0 @@ "main": "index.html",

@@ -11,2 +11,24 @@ <h1>lockandload AMD-loader</h1>

## Why
After reviewing the javascript-loader landscape, looking for a loader
that satisfies the following criteria:
- Small enough to be inlined (to avoid paying an extra request-tax to
get the loader onboard).
- Inlined config file (get rid of a request).
- Config file in pure javascript (no parsing overhead).
- Let the browser do the actual loading (browsers are smart these days)
of files.
- Connect all asynchronously loaded modules together.
- Support for single page apps that include legacy code that
uses sprinkled `$(function(){...})` constructs, yet I insist on loading
jQuery late and asynchronously to speed things up.
I came to the conclusion that (apparently?) none of the existing loaders
fit the bill. So I wrote `lockandload` back in 2014 and used it in
various internal projects, but decided to open-source
it now in case others find it useful. As always, when open-sourcing something,
actually writing documentation takes most of the time. The documentation
can always be improved. Suggestions are welcome!
## Features

@@ -131,2 +153,11 @@

### Module ids
Module ids are short strings that uniquely identify a module.
In `lockandload` these ids typically do not contain parts of a path.
If a module id is derived from the javascript filename that is being
loaded, it will only refer to the final path component without
`.js` or version extension (i.e. anything after the last `/` and
before the first `.`).
### Globally

@@ -136,12 +167,19 @@ - `define(id?, dependencies?, factory)`<br />

entrypoint](https://github.com/amdjs/amdjs-api/blob/master/AMD.md).
To figure out module ids of all
the modules that you are trying to load, uncomment some debugging code
in the primary load script and inspect your console-pane in the browser.
- `id` declares the module id we are defining. If omitted, we derive
a module id from the name of the javascript file we are loading.
- `dependencies` is an array of strings of module ids this module depends on.
If the parameter is missing, a default dependency list of
`["require", "exports", "module"]` is supplied.
- `factory` is the callback function that gets called as soon as
all dependencies have been loaded. The factory function gets
references to all the exported symbols from its dependencies, and
should subsequently return its own symbols it wants to export to
other modules. The factory can be a function or a static object.
If you are in need of the common global `require(dependencies, factory)`,
insert the following code into the loader (preferably in the custom-code
section of the secondary headready-script):
```javascript
function require(d, f) { define(1, d, f); }
```
- `require(dependencies, callback)`<br />
Allows you to load dependencies (an array of strings of module ids)
asynchronously, the callback is called
as soon as all dependencies have loaded. Parameters to the callback
are references to the dependencies just as in the factory function
in `define`.

@@ -159,5 +197,29 @@ ### Locally

- `jsa(alias, path)`<br />
Define aliases for javacsript file paths to be referenced through
Define aliases for javascript file paths to be referenced through
`require.load(alias)` to load the file on demand.
### Standard require module
If you use `"require"` in your dependencylist, you get a reference to the
internal require-module. It supports the following functionality:
- `require(id)`<br />
Returns a reference to the exports of module `id`. Beware:
this will not trigger loading that module, if the module is not loaded
because it was already in your dependencylist, or if the module is
not being requested by other modules, this will return zero.
As such, it can be used to find out if a certain module is being loaded
at all.
- `require.undef(id)`<br />
Clears the cached module `id` exported symbols list. This allows the module
to be hot-reloaded by a subsequent `require.load()`. Beware that existing
references to the old module are not overwritten. Any modules using
`require(id)` before the `require.load()` will return zero, any modules
using `require(id)` after the `require.load()` will return a reference
to the exports of the reloaded module.
- `require.load(file)`<br />
Asynchronously loads the referenced javascript file. To centralise
file-location management, it is advisable to use `jsa()` calls in the
headready section to declare aliases for javascript files which can
be used instead of actual file paths in the `require.load()` calls.
### Dealing with jQuery

@@ -228,2 +290,3 @@ In order to support legacy code that uses inline `$(function(){...})` scattered

- [tinyamd](https://github.com/briancray/tinyamd).
- [CrocoDillon](https://github.com/CrocoDillon/define).
- [tAMD](https://github.com/jivesoftware/tAMD).

@@ -235,1 +298,3 @@ - [almond](https://github.com/requirejs/almond).

- [nodules](https://github.com/kriszyp/nodules).
- [Liferay](https://github.com/liferay/liferay-amd-loader).
- [lodJS](https://github.com/yanhaijing/lodjs).

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc