New to Telerik UI for Blazor? Start a free 30-day trial
Remove Components from telerik-blazor.js
Updated over 6 months ago
Environment
| Product |
UI for Blazor, PDF Viewert for Blazor, Spreadsheet for Blazor |
Description
This KB article answers the following questions:
- How to build the
telerik-blazor.jsfile without some of the components? - How to exclude components from the Telerik Blazor JSInterop file and rebuild
telerik-blazor.js? - How to remove components from the client-side code of Telerik UI for Blazor?
- How to remove the Spreadsheet component from
telerik-blazor.jsin order to achieve strict Content Security Policy compliance? - How to remove the PDF Viewer component from
telerik-blazor.jsin order to avoid conflicts with other third-party tools that depend on PDF.js? - How to reduce the file size of the Telerik Blazor JavaScript asset?
Solution
Here are the required steps to exclude Telerik UI for Blazor components from telerik-blazor.js and rebuild the Telerik JSInterop file.
- Login to your Telerik account.
- Download the source code of Telerik UI for Blazor.
- Read the
Readme.txtin the root folder of the downloaded ZIP archive. It provides information about JavaScript build pre-requisites and where to find the newly built file. - Delete the unwanted component folder from
/javascript/src/, for example:pdf-viewerfor the PDF Viewerspreadsheetfor the Spreadsheet
- Remove the
exportstatement for the unwanted component from/javascript/src/main.ts, for example:export * from './pdf-viewer/main';for the PDF Viewerexport * from './spreadsheet/main';for the Spreadsheet
- Remove any existing dependencies for the unwanted component from
/javascript/package.json, for example:@progress/kendo-pdfviewer-commonfor the PDF Viewer@progress/kendo-spreadsheet-commonfor the Spreadsheet
- Delete
/javascript/package-lock.json - Run
npm installin thejavascriptfolder. - Run
gulp build-cdnin thejavascriptfolder. - Copy the generated
telerik-blazor.jsfile to thewwwrootfolder or your Blazor app. - Remove the existing
telerik-blazor.jsfile registration as a static asset or CDN URL. Register the customtelerik-blazor.jsfromwwwroot.
Repeat the above steps and rebuild
telerik-blazor.jsafter every version update of Telerik UI for Blazor.