Skip to content Skip to sidebar Skip to footer

Loading Spin.js With Require.js

I recently started a Javascript project and I am now moving it to require.js. Everything worked fine so far except for the spin.js library. I get the following error message when I

Solution 1:

The spin library should not be shimmed in your config. From the spin.js source code:

  if (typeof define == 'function' && define.amd)
    define(function() { return Spinner })
  else
    window.Spinner = Spinner

It is already defined as a module here at the end, and window.Spinner is not created as a window object (which is why it shouldn't be shimmed)


Solution 2:

I had a case of something similar. I didn't add to shim but neglected to add Spinner to the function after Backbone which caused it to be undefined.

define([
  'jquery',
  'underscore',
  'backbone',
  'spin'
],

function($, _, Backbone, Spinner) {
  var SpinnerView = Backbone.View.extend({

    initialize: function() {

      this.loadingAnimation();
    },

Post a Comment for "Loading Spin.js With Require.js"