# Using Telerik UI for ASP.NET MVC with RequireJS

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC</td>
 </tr>
 <tr>
  <td>Product Version</td>
  <td>Created with version 2024.4.1112</td>
 </tr>
</table>

## Description

How can I use [RequireJS](https://requirejs.org/) in a [Telerik UI for ASP.NET MVC application](https://www.telerik.com/aspnet-mvc/documentation/introduction)?

## Solution

The following example demonstrates how to use bundled scripts with RequireJS to initialize a [Grid](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview) component.

1. Include the desired [Kendo UI theme](https://www.telerik.com/aspnet-mvc/documentation/styles-and-layout/sass-themes/overview) and the RequireJS script.
2. Initialize the Grid component and [defer its initialization script](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/helper-basics/deferred-initialization) using the [`Deferred()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/gridbuilder#deferredsystemboolean) method.
3. Use RequireJS to load jQuery and the [required Kendo UI scripts](https://www.telerik.com/aspnet-mvc/documentation/installation/adding-client-side-resources/getting-started-copy-client-resources).
4. Initialize the Grid by calling the `DeferredScripts()` method in the `initApp()` function.

```Razor Index.cshtml
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@@progress/kendo-theme-default@10.0.1/dist/all.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.1/require.js"></script>

    @(Html.Kendo().Grid<Telerik.Examples.Mvc.Areas.RequireJS.Models.Product>()
        .Name("grid")
        .DataSource(dataSource => dataSource.Ajax().Read("Read", "Home"))
        .Deferred()
    )

    <script>
        require.config({
            baseUrl: "https://cdn.jsdelivr.net/npm/@@progress/kendo-ui@2024.4.1112/umd/",
            paths: {
                "jquery": "https://code.jquery.com/jquery-3.7.1.min",
                "jszip": "https://unpkg.com/jszip/dist/jszip.min.js",
                "kendo.grid.min": "https://cdn.jsdelivr.net/npm/@@progress/kendo-ui@2024.4.1112/umd/kendo.all.min",
                "kendo.aspnetmvc.min": "https://cdn.jsdelivr.net/npm/@@progress/kendo-ui@2024.4.1112/umd/kendo.aspnetmvc.min"
            }
        });

        require(["jquery", "jszip", "kendo.grid.min", "kendo.aspnetmvc.min" ], initApp);

        function initApp($, JSZip, kendo) {
            window.JSZip = JSZip;

            @Html.Kendo().DeferredScripts(false)
        }
    </script>
```

For a runnable example, refer to the [ASP.NET MVC application](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/RequireJS) in the [UI for ASP.NET MVC Examples repository](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master).

## More ASP.NET MVC Resources

* [Telerik UI for ASP.NET MVC Product Page](https://www.telerik.com/aspnet-mvc)

* [Telerik UI for ASP.NET MVC Demos](https://demos.telerik.com/aspnet-mvc/)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forum](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [RequireJS Integration in Kendo UI for jQuery](https://docs.telerik.com/kendo-ui/third-party/using-kendo-with-requirejs)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2024-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
