Skip to content

Commit

Permalink
docs(common):Add another reason for js error (#2451)
Browse files Browse the repository at this point in the history
* docs(common):Add another framework reason for js error

* update after review
  • Loading branch information
NansiYancheva authored Oct 23, 2024
1 parent 4b492aa commit 53556fc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions troubleshooting/js-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ If you get such errors, the reason may be:

* [The `telerik-blazor.js` JS Interop file is missing or the URL is wrong](#missing-file)
* [The `defer` attribute causes the script to load and execute too late](#defer-attribute)
* [A required order of the HTML tags in the web page](#html-tags-order)
* [TypeScript `exports` workaround break Telerik Blazor](#typescript)
* [A result of a syntax error in old browser](#syntaxerror-unexpected-token)

Expand All @@ -57,6 +58,21 @@ Sometimes, the JS Interop file is referenced correctly and returns successfully,

One solution is to remove the `defer` attribute of the `<script>` tag that registers `telerik-blazor.js`. On the other hand, `defer` improves the performance of your app by loading the script asynchronously. That's why a better option is to [keep the `defer` attribute and start the client-side Blazor framework manually]({%slug getting-started/what-you-need%}#javascript-file).

### HTML Tags Order

You can get the error when the application is navigating from an interactive page. If this is the case, register the `telerik-blazor.js` after the `<base href="/" />` in the `<head>` of the web page:

<div class="skip-repl"></div>

```HTML
<head>
...
<base href="/" />
<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script>
...
</head>
```

### TypeScript

By default, TypeScript results in compiled code that needs the `exports` object, and that is not available in Blazor by default, so it throws an error. A common workaround for that (defining an empty `exports` object) causes errors from the Telerik JS Interop files. You can read more about the errors and the solutions in the [TypeScript Exports error breaks Telerik Blazor]({%slug common-kb-typescript-exports%}) Knowledge Base article.
Expand Down

0 comments on commit 53556fc

Please sign in to comment.