Expire cache on require.js data-main

How are you defining your require.config? I think for it to take effect before you import require.js, you need to code it like this: <script type=”text/javascript”> var require = { baseUrl: “/scripts/”, waitSeconds: 15, urlArgs : “bust=”+new Date().getTime() }; </script> <script data-main=”app/main” src=”https://stackoverflow.com/scripts/require.js”></script> Specifically, a an object named ‘require’ must be constructed before you import …

Read more

Why do we need a Single Page Application? [closed]

I believe that this is the direction most websites should be moving in considering the number of devices that users utilize today, and the abilities and limitations of each. IMPORTANT: Before reading the rest of this, please understand that this concept is built on the foundation of basic principles of designing for the web. In …

Read more

Requirejs why and when to use shim config

A primary use of shim is with libraries that don’t support AMD, but you need to manage their dependencies. For example, in the Backbone and Underscore example above: you know that Backbone requires Underscore, so suppose you wrote your code like this: require([‘underscore’, ‘backbone’] , function( Underscore, Backbone ) { // do something with Backbone …

Read more

How to disable the warning ‘define’ is not defined using JSHint and RequireJS

Just to expand a bit, here’s a .jshintrc setup for Mocha: { …. “globals” : { /* MOCHA */ “describe” : false, “it” : false, “before” : false, “beforeEach” : false, “after” : false, “afterEach” : false } } From the JSHint Docs – the false (the default) means the variable is read-only. If you …

Read more

Relation between CommonJS, AMD and RequireJS?

RequireJS implements the AMD API (source). CommonJS is a way of defining modules with the help of an exports object, that defines the module contents. Simply put, a CommonJS implementation might work like this: // someModule.js exports.doSomething = function() { return “foo”; }; //otherModule.js var someModule = require(‘someModule’); // in the vein of node exports.doSomethingElse …

Read more