Git Product home page Git Product logo

zerodep's Introduction

ZeroDep

Build Status

A simple Zero Dependency, dependency management framework

Problem - What problem does this solve?

Many JavaScript web dependency frameworks require you to have the framework loaded before doing ANYTHING. This framework and "method" does not require code to be run in ANY particular order. That means you could have this library loaded last and still have everything run in the right order.

  • This is particularly useful if you simply concatenate and minify JS files together without regard for ordering.
  • Also useful if you have no control of where and when JS code runs.
    • Many large organizations have lots of different groups that edit and maintain different parts of a page. This approach helps unify JS into a common framework slowly over time.

Getting Started

Step 0. Download ZeroDep

Download and place the ZeroDep JavaScript library somewhere accessible via the web.

Step 1. Include the ZeroDep JavaScript somewhere in your pages.

All dependencies and code requiring dependencies will be run after ZeroDep has run (code can of course be placed and loaded before). So if you want code to run in the HEAD html tag ZeroDep needs to load and run in the HEAD html tag.

Via HTML Script tag

<script src="zerodep.js"></script>

OR

<script src="zerodep.js" async></script>

OR

Copy and paste the code into your script files or inline it in a script block in the HTML

Step 2. Start using Zero Dep

Defining dependencies

(window.ZDQ = window.ZDQ || []).push(function(zd) {
  zd.def("NameOfDependency", function() {
    return "ArgumentToExpose";
  });
});

OR (if you know the ZeroDep lib has loaded)

zd.def("NameOfDependency", function() {
	return "ArgumentToExpose";
});

Requiring dependencies

(window.ZDQ = window.ZDQ || []).push(function(zd) {
  zd.req("Dependency", function(fromDefine) {
    //Do your stuff
  });
});

Requiring multiple dependencies

(window.ZDQ = window.ZDQ || []).push(function(zd) {
  zd.req(["Dependency1","Dependency2"], function(fromDep1, fromDep2) {
    //Do your stuff
  });
});

OR (if you know the ZeroDep lib has loaded)

zd.req("Dependency", function(fromDefine) {
  //Do your stuff
});

Requiring multiple dependencies

zd.req(["Dependency1","Dependency2"], function(fromDep1, fromDep2) {
  //Do your stuff
});

Requiring and Defining dependencies together

(window.ZDQ = window.ZDQ || []).push(function(zd) {
  zd.reqDef("RequiredDep", "NewDepName", function(FromRequiredDep) {
    //Do your stuff
    return "NewDepArgumentToExpose";
  });
});

Requiring multiple dependencies

(window.ZDQ = window.ZDQ || []).push(function(zd) {
  zd.reqDef(["RequiredDep1", "RequiredDep2"], "NewDepName", function(FromRequiredDep1, FromRequiredDep2) {
    //Do your stuff
    return "NewDepArgumentToExpose";
  });
});

OR (if you know the ZeroDep lib has loaded)

zd.reqDef("RequiredDep", "NewDepName", function(FromRequiredDep) {
  //Do your stuff
  return "NewDepArgumentToExpose";
});

Requiring multiple dependencies

zd.reqDef(["RequiredDep1", "RequiredDep2"], "NewDepName", function(FromRequiredDep1, FromRequiredDep2) {
  //Do your stuff
  return "NewDepArgumentToExpose";
});

zerodep's People

Contributors

shmcsensei avatar simonchong avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.