Radzen.Blazor.js Exception #1478

Closed
opened 2026-01-29 17:54:11 +00:00 by claunia · 7 comments
Owner

Originally created by @Ezekiel768 on GitHub (Nov 15, 2024).

Exception generated from line 20 in https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/wwwroot/Radzen.Blazor.js when load is on startup and document.fonts exists.
This should wait for the document to be ready first.
This causes the rest of the file to fail execution.

image

Issue stems from commit: 7e640f47a5

Originally created by @Ezekiel768 on GitHub (Nov 15, 2024). Exception generated from line 20 in https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/wwwroot/Radzen.Blazor.js when load is on startup and `document.fonts` exists. This should wait for the document to be ready first. This causes the rest of the file to fail execution. ![image](https://github.com/user-attachments/assets/ee59dae1-753e-48af-954b-96a97985a182) Issue stems from commit: https://github.com/radzenhq/radzen-blazor/commit/7e640f47a5bac0e6adf8f77d636b124b4df027e8
Author
Owner

@akorchev commented on GitHub (Nov 15, 2024):

You should include the Radzen.Blazor.js file in the <body> and this error will not happen.

@akorchev commented on GitHub (Nov 15, 2024): You should include the Radzen.Blazor.js file in the `<body>` and this error will not happen.
Author
Owner

@Ezekiel768 commented on GitHub (Nov 15, 2024):

You should include the Radzen.Blazor.js file in the <body> and this error will not happen.

That's not standard, it should be in the head, not body. I've created a PR: https://github.com/radzenhq/radzen-blazor/pull/1791

This is a simple fix, pretty sure your response took longer.

@Ezekiel768 commented on GitHub (Nov 15, 2024): > You should include the Radzen.Blazor.js file in the `<body>` and this error will not happen. That's not standard, it should be in the `head`, not `body`. I've created a PR: https://github.com/radzenhq/radzen-blazor/pull/1791 This is a simple fix, pretty sure your response took longer.
Author
Owner

@akorchev commented on GitHub (Nov 15, 2024):

That's not standard, it should be in the head, not body

That is not true. The default Microsoft Blazor template includes the script in the <body>. As per our official instructions the script should be included after the blazor.web.js file.

@akorchev commented on GitHub (Nov 15, 2024): > That's not standard, it should be in the head, not body That is not true. The default Microsoft Blazor template includes the script in the `<body>`. As per our official instructions the script should be included after the `blazor.web.js` file.
Author
Owner

@Ezekiel768 commented on GitHub (Nov 15, 2024):

That's not standard, it should be in the head, not body

That is not true. The default Microsoft Blazor template includes the script in the <body>. As per our official instructions the script should be included after the blazor.web.js file.

After this comment, I took some time to consider what is happening here. Initially I was in a rush to fix our application running this library.

I don't think the placement of the JavaScript file is the real issue here. What made me open this issue was the fact that a library broke my application, with no warning. (silent, where is the try catch?)

Placing JavaScript files that work with components in the body isn't bad, but actually recommended for performance: Microsoft Learn. This made me learn something, thanks.

However, Radzen being a component library, should adhere to common best practice. Common best practice dictates that a component should not change what it did not create. You should not modify body, you did not create it. This brings more predictability into the equation.

Perhaps consider another approach in handling your icon loading.

@Ezekiel768 commented on GitHub (Nov 15, 2024): > > That's not standard, it should be in the head, not body > > That is not true. The default Microsoft Blazor template includes the script in the `<body>`. As per our official instructions the script should be included after the `blazor.web.js` file. After this comment, I took some time to consider what is happening here. Initially I was in a rush to fix our application running this library. I don't think the placement of the JavaScript file is the real issue here. What made me open this issue was the fact that a library broke my application, with no warning. **(silent, where is the try catch?)** Placing JavaScript files that work with components in the `body` isn't bad, but actually recommended for performance: [Microsoft Learn](https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/location-of-javascript?view=aspnetcore-9.0&preserve-view=true#:~:text=Loading%20JS%20from%20the%20%3Chead%3E%20isn%27t%20the%20best%20approach%20for%20the%20following%20reasons%3A). This made me learn something, thanks. However, Radzen being a component library, should adhere to common best practice. Common best practice dictates that a component should not change what it did not create. You should not modify `body`, you did not create it. This brings more predictability into the equation. Perhaps consider another approach in handling your icon loading.
Author
Owner

@akorchev commented on GitHub (Nov 15, 2024):

You should not modify body, you did not create it. This brings more predictability into the equation.

You seem to have no issue with the blazor.web.js file being in the body. Why the double standards :) Anyway I have pushed a check so people who insist not to follow the instructions won't have a JS error (and of course preloading the icon font won't work as a result for them).

@akorchev commented on GitHub (Nov 15, 2024): > You should not modify body, you did not create it. This brings more predictability into the equation. You seem to have no issue with the blazor.web.js file being in the body. Why the double standards :) Anyway I have pushed a check so people who insist not to follow the instructions won't have a JS error (and of course preloading the icon font won't work as a result for them).
Author
Owner

@Ezekiel768 commented on GitHub (Nov 15, 2024):

You should not modify body, you did not create it. This brings more predictability into the equation.

You seem to have no issue with the blazor.web.js file being in the body. Why the double standards :) Anyway I have pushed a check so people who insist not to follow the instructions won't have a JS error (and of course preloading the icon font won't work as a result for them).

I refer:

Placing JavaScript files that work with components in the body isn't bad, but actually recommended for performance: Microsoft Learn. This made me learn something, thanks.

The above agrees to JavaScript files being added to body, as correct. There are no double standards.

But, I don't think you understand what I am saying. Modifying body includes adding a class to to it: aecee331a4/Radzen.Blazor/wwwroot/Radzen.Blazor.js (L20)
A library, should not modify what it did not create.
Your confrontational response is not appreciated.

@Ezekiel768 commented on GitHub (Nov 15, 2024): > > You should not modify body, you did not create it. This brings more predictability into the equation. > > You seem to have no issue with the blazor.web.js file being in the body. Why the double standards :) Anyway I have pushed a check so people who insist not to follow the instructions won't have a JS error (and of course preloading the icon font won't work as a result for them). I refer: > Placing JavaScript files that work with components in the body isn't bad, but actually recommended for performance: [Microsoft Learn](https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/location-of-javascript?view=aspnetcore-9.0&preserve-view=true#:~:text=Loading%20JS%20from%20the%20%3Chead%3E%20isn%27t%20the%20best%20approach%20for%20the%20following%20reasons%3A). This made me learn something, thanks. The above agrees to JavaScript files being added to body, as correct. There are no double standards. But, I don't think you understand what I am saying. Modifying `body` includes adding a class to to it: https://github.com/radzenhq/radzen-blazor/blob/aecee331a44b6216c2534919149d6d81c4e3c096/Radzen.Blazor/wwwroot/Radzen.Blazor.js#L20 A library, should not modify what it did not create. Your confrontational response is **not** appreciated.
Author
Owner

@akorchev commented on GitHub (Nov 15, 2024):

A lot of libraries add classes to the body element. We will continue doing so. Your confrontational comments are also not appreciated - feel free to use a different library which doesn't add classes to the body element.

@akorchev commented on GitHub (Nov 15, 2024): A lot of libraries add classes to the body element. We will continue doing so. Your confrontational comments are also not appreciated - feel free to use a different library which doesn't add classes to the body element.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1478