Question

I'm currently working with YepNope.js to load my css/javascript files. I was wondering if there is any way to give the scripts a variable name during the initial process. For instance:

yepnope({
    test : Modernizr.csstransforms,
    yep  : ['MyCSS', 'jQuery']
    nope : ['MyCSS2']
});

// Where 'MyCSS' = '/css/mycss.css' | 'jQuery' = '/scripts/jquery.min.js' 
// 'MyCSS2' = '/css/mycss2.css

I have a team of devs that would all be using the same set of scripts and want to make it as easy as possible to handle. Having to track down the script paths may prove time consuming over simple name assignments.

I want to be able to define a list of variable names that have the values of the actual script assigned to them that YepNope.js will interpret without the developer having to add the variable assignments to their projects code:

{ 'MyCSS': '/css/mycss.css', 'jQuery', '/scripts/jquery.min.js' }

That way when the developer adds their script files to their project they don't have to track down all the paths for the specified files.

Was it helpful?

Solution

Is this what you need?

var yeps = ['/css/mycss.css','/scripts/jquery.min.js'];
var nopes = ['/css/mycss2.css'];

yepnope({
    test : Modernizr.csstransforms,
    yep  : yeps,
    nope : nopes
});

or

var myCSSpath= '/css/mycss.css',
    jQpath = '/scripts/jquery.min.js',
    myCSS2path = '/css/mycss2.css';

yepnope({
    test : Modernizr.csstransforms,
    yep  : [myCSSpath, jQpath],
    nope : [myCSS2path]
});

EDIT: so you want to put the variable assignments to a different file?

make a yepnope.variables.js

<script src="path/yepnope.js"></script>
<script src="path/yepnope.variables.js"></script>

<script>
yepnope({
    test : Modernizr.csstransforms,
    yep  : [myCSSpath, jQpath],
    nope : [myCSS2path]
});
</script>

and inside the js file:

var myCSSpath= '/css/mycss.css',
    jQpath = '/scripts/jquery.min.js',
    myCSS2path = '/css/mycss2.css';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top