I've spent more than half a day trying to set up a requirejs, socket.io, backbonejs fiddle so as to solve another SO question.
Here is what I tried. You may checkout my fiddle I tried a couple ways without any luck.
- I've loaded the scripts in the head like this.
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.js"></script>
<script>
requirejs.config({
paths: {
'socket.io': ['https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.5.1/socket.io.js'],
'jquery': ['https//cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js'],
'underscore': ['https//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js'],
'backbone': ['https//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js']
},
shim: {
'backbone': ['underscore']
},
waitSeconds: 3
});
</script>
</head>
<body>
<div id='page'>
<div id='incomingChatMessages'>
</div>
</div>
</body>
</html>
Here is how I tried to load the scripts in the js component otherwise
requirejs.config({ paths: { 'socket.io': ['https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.5.1/socket.io.js'], 'jquery': ['https//cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js'], 'underscore': ['https//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js'], 'backbone': ['https//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js'] }, shim: { 'backbone': ['underscore'] }, waitSeconds: 3 }); var io = require('socket.io') var $, Backbone; require(['jquery', 'underscore', 'backbone'], function(jq, us, bb) { $ = jq; Backbone = bb; }); Backbone.$ = $;
here is a link by someone who is loading jquery using requirejs in a jsfiddle but that only addresses my problem partially