New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path list as a array #139

Closed
sjoonk opened this Issue May 13, 2011 · 5 comments

Comments

Projects
None yet
5 participants
@sjoonk

sjoonk commented May 13, 2011

I'd like to change the path list of head.js method.
Is there any way to pass the path list as an array??

@CreativeTransmissions

This comment has been minimized.

Show comment
Hide comment
@CreativeTransmissions

CreativeTransmissions Aug 9, 2011

I'm just testing this on a large project and found the following method works for loading in parallel and executing in sequence:

//Create or generate an array of scripts
var scripts = ['Includes/error.js', /adapter/ext/ext-base.js', '/Components/cmpBase.js'];

//Use Javascript's apply method to call the head.js function
head.js.apply(window, scripts);

Hope this helps someone.

CreativeTransmissions commented Aug 9, 2011

I'm just testing this on a large project and found the following method works for loading in parallel and executing in sequence:

//Create or generate an array of scripts
var scripts = ['Includes/error.js', /adapter/ext/ext-base.js', '/Components/cmpBase.js'];

//Use Javascript's apply method to call the head.js function
head.js.apply(window, scripts);

Hope this helps someone.

@EnzoMartin

This comment has been minimized.

Show comment
Hide comment
@EnzoMartin

EnzoMartin Dec 18, 2012

Wishing we could pass in an array, that'd be really useful.

The .apply work-around doesn't make for easy callback handling

EnzoMartin commented Dec 18, 2012

Wishing we could pass in an array, that'd be really useful.

The .apply work-around doesn't make for easy callback handling

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 18, 2012

Contributor

will give this some more thought.

The apply example would look like this more likely with a callback

head.js.apply(window, scripts.push(callback));
Contributor

ghost commented Dec 18, 2012

will give this some more thought.

The apply example would look like this more likely with a callback

head.js.apply(window, scripts.push(callback));
@EnzoMartin

This comment has been minimized.

Show comment
Hide comment
@EnzoMartin

EnzoMartin Dec 18, 2012

I wrote a quick workaround for my own purposes for now, nothing fancy:

var args      = arguments,
     callback = args[args.length - 1],
     items    = {};

if (!isFunction(callback)) {
    callback = null;
}

 if (isArray(args[0])) {
    var arrArgs = args[0];
    args = [];
    each(arrARgs, function (arg) {
        args.push(arg);
    });
    args.push(callback);
}

EnzoMartin commented Dec 18, 2012

I wrote a quick workaround for my own purposes for now, nothing fancy:

var args      = arguments,
     callback = args[args.length - 1],
     items    = {};

if (!isFunction(callback)) {
    callback = null;
}

 if (isArray(args[0])) {
    var arrArgs = args[0];
    args = [];
    each(arrARgs, function (arg) {
        args.push(arg);
    });
    args.push(callback);
}
@robert-hoffmann

This comment has been minimized.

Show comment
Hide comment
@robert-hoffmann

robert-hoffmann Nov 4, 2013

Member

Shipping in 1.0.0

Member

robert-hoffmann commented Nov 4, 2013

Shipping in 1.0.0

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