Skip to content

Instantly share code, notes, and snippets.

@davidpadbury
Created October 25, 2010 01:24
Show Gist options
  • Save davidpadbury/644247 to your computer and use it in GitHub Desktop.
Save davidpadbury/644247 to your computer and use it in GitHub Desktop.
yepnope wait order
yepnope([
{
load: 'http://code.jquery.com/jquery-1.4.3.min.js',
callback: function(){}
},
{
test: Modernizr.input.placeholder,
nope: 'js/jquery.placeholder.js',
callback: function(inc, testResult) {
$('input, textarea').placeholder();
}
}
]);
@SlexAxton
Copy link

That's ugly, isn't it...

Help me come up with a better api for forcing in order loading.

How about?

yepnope([
  {
    load: 'jquery.js',
    wait: true
  },
  {
    test: Modernizr.input.placeholder,
    nope: 'js/jquery.placeholder.js',
    callback: function(inc, testResult) {
      $('input, textarea').placeholder();
    }
  }
]);

A callback will still do it naturally, but the wait param might be clearer if that's all you're using the callback for...

Yes?

@davidpadbury
Copy link
Author

Yep, much clearer for when you don't need a callback. Also wait will be familiar to those who've used LabJS. I've sent a pull based on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment