Giter Site home page Giter Site logo

jsdefer's People

Contributors

borismoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsdefer's Issues

Appears to only load last $.defer() call.

I'm also seeing an issue where it appears to only actually load the last $.defer() called script it finds if there are multiple scripts with calls to $.defer() in a page.

I'm attempting to replace the old script loader from codeplex with this.

Support including css links

Add support for including css links in the loader... Just for convenience of using one thing to include everything, and it is only a few more lines of code.

jQuery Lazy loading doesn't work in IE9

Trying to lazy load jQuery is throwing 4 script errors around line 414 of jsdefer.js.
I included jsdefer.js in the head, put in a def for jQuery in another script include under it as such:

var GoogleCDN = "//ajax.googleapis.com/ajax/libs";
var MicrosoftCDN = "//ajax.aspnetcdn.com/ajax";

var jQueryRelease = GoogleCDN + "/jquery/1.5.1/jquery.min.js"; //MicrosoftCDN + "/jquery/jquery-1.5.1.min.js";
var jQueryDebug = GoogleCDN + "/jquery/1.5.1/jquery.js"; //MicrosoftCDN + "/jquery/jquery-1.5.1.js";

jQueryRelease = (proto === "https" ? jQueryRelease : "//code.jquery.com/jquery-latest.min.js");
jQueryDebug = (proto === "https" ? jQueryDebug : "//code.jquery.com/jquery-latest.js");

$.deferDef({
jQuery: {
bare: true,
minUrl: jQueryRelease,
url: jQueryDebug
// OLD LOAD CHECK = isLoaded: !!(window.jQuery && jQuery.ui)
}
});

isLoaded feature

When a script is loaded on the page via script tag and then jsdefer tries to include it jsdefer should test for it.

jsdefer should provide a boolean expression test configurable in the script definition via deferDef... The old Sys.loader had this feature and it allows conditionally including a script based on how you define it. There are lots of uses for this...

Load script B only if script A is there (assuming you're not using jsdefer exclusively for script loading (we can't totally enforce it in some of our scenarios).

An Array of Script URLs

I have an array of modules names which I convert to an array of script URLs and a single callback to execute once they are all successfully loaded. Unless I have overlooked something, I have not seen a convenient way to execute this use case.

[EXPIRED] Page-based loading

There are a lot of JS loaders, really. But none of them, at least within documentation, addresses a problem I'm eager to solve. That is to use single <script> line per whole project which inits page-based loading of dependencies.

Let's create a simple project with index, portfolio, and contacts pages.

Microframework will help us with routing:

$app->get('/portfolio/',
    function () use ($app) {
        $prices = array(
              "price_mine"  => "90",
              "price_rival" => "120"
        );
        $app->render('portfolio.twig', $prices);
    });

Template engine will help us with rendering:

{% extends "base.twig" %}
{% block content %}
     <p>Aren't you sick and tired to pay {{price_rival}}…</p>.
{% endblock content %}

And the missing part in every page is <script src="/static/init.js"></script> that works as follows

  • any page loads jQuery from CDN or from my server as fallback,
  • index loads SoundManager to serve audio salutation,
  • portfolio loads Lightbox to serve images,
  • contacts loads Forms validator.

What's the best way to achieve it?
And how to do that with jsDefer whether it's possible?

Thank you in advance.
Warm regards from Russia, Alexander.

chaining when().done().when().done()

I happened across this post about chaining when().done() calls... It appears that it async loads everything and then chains the done methods together guaranteeing that they run in order. This seems more natural than having to nest a when() method inside a done() method to get this behavior. I might suggest adding this to jsdefer, or submitting to jQuery itself for inclusion...

http://www.bennadel.com/blog/2129-Experimenting-With-Sub-And-Deferred-Objects-In-jQuery-1-5.htm

Urls beginning with // are converted to relative path.

This may seem like a helper, but the :// search on line 261 should just be // because you then don't have to worry about whether it's ssl or not and can pass in a script path like this:

//www.mysite.com/scripts/whatever.js

and it will use http or https depending on what mode the page is in. if you force urls to have http: or https: in them then we have to do an unnecessary script check for ssl and provide an alternate url.

that may be an option to add to this... I might suggest the following:

minurl = local min url on your domain
url = local url on your domain
cdnminurl = CDN min url
cdnurl = CDN url

and then add ssl to all those for ssl versions. unless you want to add the ssl check in the loader itself and have it change the script urls appropriately...?

Multiple script definitions with same url will choose last definition regardless of name.

Multiple script definitions with same url will choose last definition regardless of name.

Example:

jQuery: {
    bare: true,
    url: aspnetcdn + "/jQuery/jquery-1.7.1.js",
    urlMin: aspnetcdn + "/jQuery/jquery-1.7.1.min.js",
    loaded: "!!window.jQuery"
},
jQuery171: {
    bare: true,
    url: aspnetcdn + "/jQuery/jquery-1.7.1.js",
    urlMin: aspnetcdn + "/jQuery/jquery-1.7.1.min.js",
   loaded: "window.checkjQueryVersion(171)"
},

defer call to jQuery will load jQuery171 definition script. This is not expected (loaded was different, causing test to fail in some cases, which was a bad thing)

License

Hello !

What about the license ? In which conditions can I use it ?

Thanks !

Should avoid duplicate references

When including jsdefer.js on a page, if it is already loaded it should not load again or lose its references to what scripts are loaded already.

URLs converted to lower case fail.

In some cases, urls converted to lower case fail. The Azure CDN is case sensitive. This is hypo-critical. If you're going to build a case sensitive CDN you should build a loader that is case sensitive too. I'd rather have the CDN fixed but since that isn't likely to happen, the loader needs to play nice.

is it possible to return an deferred from function called by window.$deferRun ?

an example :

i have library file containing

window.$deferRun(
function( $, options) {
      function A_processed() { 
          // ...
      }
      function B_processed() { 
          // ...
      }
           // here is the important point(!) : 
           // returning an deferred has no effect right now
      return $.when( A_processed(), b_processed());
},
{
        depends : [ 'ampere_core', 'ampere_util', 'ampere_module', 'ampere_action', 'ampere_history', 'ampere_state', 'ampere_transition', 'ampere_view', 'ampere_theme']
});

i want my library to be resolved

  • when its dependences are resolved (works fine)
  • its function was executed (works fine)
  • the returned deferred are resolved (does not work right now)

i did not find a way to return a deferred from my library function which is taken into account for its "resolved" state.
any idea how to do this ?

kind regards,

lars

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.