Download Bootstrap from CDN with Require.js

Bootstrap distributed on CDN in

http://www.bootstrapcdn.com/

  • Can I bootstrap with Require.JS 2.x (shimmed or native AMD)?

  • How can I load Bootstrap or any mini-JS directly from the CDN URL using Require.js

+44
twitter-bootstrap requirejs cdn
Nov 20 '12 at 0:30
source share
1 answer
requirejs.config({ appDir: ".", baseUrl: "js", paths: { /* Load jquery from google cdn. On fail, load local file. */ 'jquery': ['//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min', 'libs/jquery-min'], /* Load bootstrap from cdn. On fail, load local file. */ 'bootstrap': ['//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.', 'libs/bootstrap-min'] }, shim: { /* Set bootstrap dependencies (just jQuery) */ 'bootstrap' : ['jquery'] } }); require(['jquery', 'bootstrap'], function($) { console.log("Loaded :)"); return {}; }); 
+81
Nov 21 '12 at 17:33
source share



All Articles