Add UrlArgs to reuire-js main file

172 Views Asked by At

Is it possibile to add the urlArgs to main file?

require.config({
    urlArgs : "v=1.1"
});

<script data-main="js/main" src="js/require.js"></script>
1

There are 1 best solutions below

2
On BEST ANSWER

Yes, here you call require before the script is loaded. In your js/main module, you can for example :

requirejs.config({
    urlArgs : "v=1.1"
});
require(['dep'], function(dep){

});

Or better separate the config into a dedicated module (as in this sample project )

UPDATE:

If you want the parameters to be appended to the load of js/main you shouldn't use the data-main attribute:

<script src="js/require.js"></script>
<script>
requirejs.config({
    urlArgs : "v=1.1"
});
require(['js/main']);
</script>

or build the require object before loading as described in the doc (I don't know the exact syntax for the config).