barteloma
barteloma

Reputation: 6875

Javascript requirejs, arcgis and dojo difference points

When I looking for javascript modular application I found Requirejs javascript library. This library makes js applications modular. I am working on Arcgis Javascript API. In this API you can use dojo and Requirejs features. For example:

require(["esri/map", "esri/layers/FeatureLayer"], function(Map, FeatureLayer) {
        map = new Map("mapDiv", {
          basemap: "streets",
          center: [-80.94, 33.646],
          zoom: 8,
          slider: false
        });

require() and define() methods are using in Requirejs library. But using in Arcgis API same time. And Dojo API is using as well.

But when I add the scripts in same html file, Requirejs code not working.

<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"></script>
<script data-main="js/main.js" src="js/require.js"></script>

I can not separate of the requirejs and other APIs. Is Arcgis API and Dojo is including Requirejs in itself?

Upvotes: 3

Views: 609

Answers (2)

Matej
Matej

Reputation: 942

requirejs library requires a single entry point to enforce modular loading. You cannot use other script tags before the line:

<script data-main="js/main.js" src="js/require.js"></script>

Upvotes: 0

Andreas K&#246;berle
Andreas K&#246;berle

Reputation: 110972

Dojo use the same AMD syntax to load scripts but not the same syntax to configure and bootstrapping. So if you use dojo you need to switch to the dojo syntax.

Upvotes: 3

Related Questions