Skip to content

Instantly share code, notes, and snippets.

@zonak
Created November 6, 2011 05:01
Show Gist options
  • Save zonak/1342498 to your computer and use it in GitHub Desktop.
Save zonak/1342498 to your computer and use it in GitHub Desktop.
RequireJS combo
# /index.html
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="author" content="zonak">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<script src="/js/libs/modernizr.js"></script>
</head>
<body>
<header>
</header>
<div role="main">
</div>
<footer>
</footer>
<script data-main="js/main" src="/js/libs/require.js"></script>
<!-- end scripts -->
<!--[if lt IE 7 ]>
<script defer src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script defer>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->
</body>
</html>
# /js/main.js
(function() {
require.config({
baseUrl: "/js/",
paths: {
'jquery': 'libs/jquery',
'underscore': 'libs/underscore',
'backbone': 'libs/backbone',
'order': 'rjs_plugins/order'
}
});
require(['jquery', 'underscore', 'backbone', 'utils'], function($, _, Backbone, Utils) {
console.log('jQuery Version: ' + $.fn.jquery);
console.log('Underscore Version: ' + _.VERSION);
console.log('Backbone Version: ' + Backbone.VERSION);
});
}).call(this);
# /js/utils.js
(function() {
define(["jquery"], function($) {
(function(b) {
var c;
return c = function() {
var a, _i, _len, _ref, _results;
_ref = "assert,clear,count,debug,dir,dirxml,error,exception,firebug,group,groupCollapsed,groupEnd,info,log,memoryProfile,memoryProfileEnd,profile,profileEnd,table,time,timeEnd,timeStamp,trace,warn".split(",");
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
_results.push(b[a] = b[a] || c);
}
return _results;
};
})((function() {
try {
console.log();
return window.console;
} catch (err) {
return window.console = {};
}
})());
});
}).call(this);
@jrburke
Copy link

jrburke commented Nov 6, 2011

I used this to make a running example, but seems to work for me, had to modify some things, only load utils, but my concern was that there was a mismatch between baseUrl used to load main.js and the one specified in main.js, but it all seems to work out.

So I'm not sure what the problem could be.

@zonak
Copy link
Author

zonak commented Nov 6, 2011 via email

@zonak
Copy link
Author

zonak commented Nov 6, 2011

Well I think I found the offending code.
Once I removed the code from utils.js:
https://gist.github.com/1342539
the issue stopped happening. Tried adding something else in that module, everything worked fine after removing the mentioned section.
Will try to investigate further what exactly might be causing this.

@zonak
Copy link
Author

zonak commented Nov 6, 2011

Well I don't know if it helps in any way but the cause is the call to:
console.log()
in the "try" block.

Still don't know why it is not happening on your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment