Looking to optimize my requirejs project with r.js -o app.build.js
Unfortunately, the result is causing issues on my website.
As shown in the attached video, the page keeps reloading itself and the console indicates that the minified module is constantly being reloaded.
Any suggestions?
<script type="text/javascript" src="http://mysite/js/require.js"
data-main="http://mysite/js/dist/app.out.js" defer async="true">
</script>
View the buggy page:
Configuration in app.build.js
{
name: "app.main.js",
mainConfigFile: 'app.main.js',
out: "dist/app.out.js",
optimize: "uglify2",
preserveLicenseComments: false,
generateSourceMaps: false,
optimizeAllPluginResources: false,
findNestedDependencies: false,
wrap: true,
wrapShim: true,
include: ["./require.js"],
}
Code in app.main.js
requirejs.config({
paths: {
require: './require',
jquery: './vendor/js/jquery-2.1.1.min',
underscore: './vendor/js/underscore-min',
backbone: './vendor/js/backbone-min',
hbs: './vendor/js/hbs/hbs',
handlebars: './vendor/js/handlebars-v4.0.5',
},
hbs: { // optional
helpers: true,
templateExtension: 'hbs',
partialsUrl: ''
},
shim: {
handlebars: {
exports: 'Handlebars'
},
backbone: {
deps: [
'underscore',
'jquery'
],
exports: 'Backbone'
},
underscore: {
exports: '_'
}
},
});
requirejs(["app_config", "app"],function(cfg, App, noop_ahoy){
return App.initialize();
});
Update
I have multiple files, some of which contain anonymous functions. Could this be the issue?
define([
...
"jquery"
],function(