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

require.js: Access all loaded modules

Yes, require.s.contexts._.defined is an object which its keys are the module names and the values include the value returned from that module. require.s.contexts._.defined includes all the modules (either define() or require() such as the Javascript file that is the starting point of the program and is indicated using data-main for RequireJS).

Require.js is hurting my brain. Some fundamental questions about the way it loads scripts/modules

Just to clear up any confusion around exports, it’s assumed that any shim library attaches a property to the global context (window or root), or modifies an already-existing global property (e.g. a jQuery plugin). When requireJS gets the command to load a shimmed dependency, it examines the global context for a property matching the exports … Read more

Using Handlebars with Backbone

Using handlebars.js instead of underscore templating is pretty straightforward. Check out this example: https://cdnjs.com/libraries/backbone.js/tutorials/what-is-a-view (scroll to the “Loading a Template” section) SearchView = Backbone.View.extend({ initialize: function(){ this.render(); }, render: function(){ // Compile the template using underscore var template = _.template( $(“#search_template”).html(), {} ); // Load the compiled HTML into the Backbone “el” this.el.html( template ); … Read more

Invalid version specified, facebook share plugin error

I was also getting the following error even when using the standard embed code that Facebook provides. Uncaught Error: invalid version specified in sdk.js The first thing to check is that you’re including the version number in your FB.init call: FB.init({ appId: ‘your-app-id’, xfbml: true, version: ‘v2.8’ }); The now-outdated fix… …was to make a … Read more