DevExtreme jQuery/JS - Link Modules
DevExtreme comes in pre-assembled bundles. dx.viz.js includes Charts, Gauges, Funnel, VectorMap, and other data visualization UI components. dx.web.js includes Grids, Scheduler, Form, and various editors. dx.all.js compile the previous two bundles. Bundles that include a particular UI component are listed on the UI component's overview page in the API reference.
Alternatively, you can use DevExtreme modules to import only the functionality you require. Unlike the bundles, modules are compact and can be loaded on demand. This optimizes memory consumption and speeds up your application.
You can create a smaller bundle from modules using Webpack or load modules using jspm or RequireJS.
Use Webpack
Install Webpack globally.
npm install webpack -g
Install the DevExtreme package in your application folder.
npm install devextreme
Define the Webpack configuration file.
JavaScriptvar path = require('path'); module.exports = { entry: './index.js', output: { filename: 'bundle.js' } };
Link the bundle script file to your application.
HTML<script type="text/javascript" src="bundle.js" charset="utf-8"></script>
Add DevExtreme themes.
HTML<link rel="stylesheet" href="node_modules/devextreme/dist/css/dx.light.css">
Create your application's entry script and specify modules in it.
JavaScriptimport "devextreme/ui/button"; ...
Create the bundle.
webpack
To see how to use Webpack with jQuery, refer to examples on GitHub. The webpack.config.js, index.js, and index.html files contain the main code. Note that jQuery components require additional integration module.
Use jspm
Install jspm in your application folder.
npm install jspm
Install the DevExtreme package via jspm.
jspm install npm:devextreme
Link the system.js and configuration files to your HTML page.
HTML<script src="jspm_packages/system.js"></script> <script src="config.js"></script>
Create your application's entry script and specify modules in it.
JavaScriptimport "devextreme/ui/button"; ...
Import your application's main entry point on the HTML page.
HTML<script> System.import('./index.js'); </script>
See examples on how to use jspm with jQuery on GitHub. The index.js and index.html files contain the main code. Note that jQuery components require additional integration module.
Use RequireJS
Install RequireJS and DevExtreme in your application folder.
npm install requirejs devextreme
Use the RequireJS conversion tool to convert the DevExtreme modules from CommonJS to AMD and save them in the devextreme_amd directory:
npx r_js -convert node_modules/devextreme/cjs devextreme_amd
Add DevExtreme themes to your application.
HTML<link rel="stylesheet" href="node_modules/devextreme/dist/css/dx.light.css">
Link RequireJS and define its configuration object.
HTML<script src="node_modules/requirejs/require.js"></script> <script> require.config({ // ... paths: { // ... "devextreme": "devextreme_amd" } }); </script>
You can see examples on how to use RequireJS with jQuery on GitHub. The index.html file contains the main code. jQuery components require additional integration module.