0

I am just beginning to use the requirejs api, but have an initial question concerning using the google CDN.

Currently, to get the latest jquery and jqueryui I am using the following:

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="https://www.google.com/jsapi?key=myKey"></script> 
<script type="text/javascript">
//=== Load in any web modules necessary
    google.load("jquery", "1");
    google.load("jqueryui", "1");
</script>

Is it possible to use this structure, or something similar, with requirejs? If so, what would the main.js file look like?

Also, can the requirejs also control the css inclusions?

radi8
  • 528
  • 3
  • 12
  • 29

1 Answers1

0

radi8, as far as I know (& I might be mistaken) RequireJS is only useful for handling JS dependencies. In CSS you can use @import, but you need to provide a hard-coded URL. If you want more robust CSS handling I'd suggest investigating Less or Sass.

UPDATE: Actually, I've been reading up on & playing with RequireJS and found this tasty tidbit, from the API usage page:

define(["require"], function(require) {
   var cssUrl = require.toUrl("./style.css");
});

Obviously it pays to fiddle about with this, see if it suits your use-case, etc. Hope this helps.

Beatbug
  • 9
  • 5