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

require-lazy

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-lazy

A RequireJS plugin for lazy loading AMD modules packaged with r.js, automatically splitting packaged code in bundles, cache-breaking the bundles only when the code changes, and defining module metadata and module discovery in Javascript applications.

  • 0.3.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

require-lazy

A RequireJS plugin for lazy loading AMD modules packaged with r.js, automatically splitting packaged code in bundles, cache-breaking the bundles only when the code changes, and defining module metadata and module discovery in Javascript applications.

Quick Example

Main module (main.js):

define(["lazy!modules/m1", "lazy!modules/m2", "lazy!text!templates/faq.html"],
function(m1, m2, faq) {
	...
});

In the simplest case where the modules main, m1, m2 have no common dependencies, Require-Lazy build scripts will create 4 separate bundles. One will contain main.js and lazy.js, one m1.js and all its dependencies, one m2.js and all its dependencies and one text.js and faq.html.

The URL for each module will look like:

/scripts/app/m1-built.js?v=684beaf379a164c2d4044a74f22ffc6d

The v request parameter is a hash of the contents of the built file, used as cache-breaker.

The lazy plugin will replace each lazy module with a lazy stub. The stub has (for the time) one method, get() that returns a promise for the real module:

m1.get().done(function(m) {
	// here m is the real module
});

A more detailed discussion and an example project setup can be found in the examples/simple directory.

Dependencies

This project requires, includes, or uses code from:

  • Node.js (required for building the target app and running the examples)
  • requirejs
  • almond
  • lazyload
  • r.js
  • node.extend
  • jQuery (dependency on Deferred implementation, can use any other library through adapter; see this test for an example)
  • expressjs (for serving the examples)

Development Status

This project is an idea under development. While many things work, it is expected that many more will not. Even worse, some things may not work as expected. Moreover the code is not thoroughly tested yet.

However, I am quite satisfied with how things work at the moment; I do not expect any radical API/usage changes. This means that this project can be considered fairly stable API/usage-wise.

Ideas, critisism, comments, code contributions are all welcome!

FAQs

Package last updated on 20 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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