Reputation: 9346
I've been playing with BackboneJS, MarionetteJS and RequireJS recently and was wondering how to include an external script with paramaters and settings?
Normally it would be included like so:
<script src="http://domain.com/api.js?apikey=API_KEY">
{
settingOne: "settingOneValue",
settingTwo: "settingTwoValue"
}
</script>
Is it possible to do something similar with RequireJS? The script is needed reasonably globally for a project so could be added "normally" if needs be.
Additional/optional requirement: Preferably the APIKEY
will be stored in an external file with other project settings.
Upvotes: 0
Views: 174
Reputation: 8413
You may use urlArgs: extra query string arguments appended to URLs that RequireJS uses to fetch resources.
Or other option would be to write custom loader plugin, that would have logic that you need.
Upvotes: 1