0

I am using Google CDN in order to get DOJO.

This the code I am using in my website.

<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.3/dojo/dojo.js"></script>

When calling in my code module 'dojo/parser' like this

define([
    'dojo/topic',
    'dojo/parser',
    'dijit/registry'
], function (topic, parser) {
    var instance;

    function Test() {
    }
    Test.prototype = {
        init: function () {
            }.bind(this));
        }
    };
    return function getInstance() {
        return (instance = (instance || new Test()));
    };
});

I get 404 not found for module parser. It actually point to Google CDN at address:

http://ajax.googleapis.com/ajax/libs/dojo/1.10.3/dojo/dojo.js/parser.js

  • Why module is missing on CDN? Or Am I missing something in my code?
  • Any idea from where or how to load it?

Notes: If I am manually change the address to

http://ajax.googleapis.com/ajax/libs/dojo/1.10.3/dojo/parser.js

I get the file, could be a bug?

GibboK
  • 71,848
  • 143
  • 435
  • 658
  • 1
    I'm having no problems with that URL. Do you have any custom packages configured in `dojoConfig`? Here's a working example with the same URL you're using: http://plnkr.co/edit/xgEi6qAPqKSNrUaoOQch?p=preview – g00glen00b Feb 13 '15 at 10:07
  • I have the same problem, have you tried to define a module loading explicitly the parse module? – GibboK Feb 13 '15 at 10:22
  • you are right a find the problem in custom packages, please add it as answer I will accept it. Thanks – GibboK Feb 13 '15 at 10:38

1 Answers1

1

The problem is not within the URL, but probably due to some custom packages configured using dojoConfig.

Here's an example (without additional configuration) that does work: http://plnkr.co/edit/xgEi6qAPqKSNrUaoOQch?p=preview

If you you have custom modules and you're using a CDN, you should probably follow the guidelines described in this article. For example:

<script>
    var dojoConfig = {
        async: true,
        packages: [{
            name: 'custom',
            location: location.pathname.replace(/\/[^/]+$/, '') + '/custom'
        }]
    };
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.3/dojo/dojo.js"></script>
g00glen00b
  • 41,995
  • 13
  • 95
  • 133