Here’s how you can do it:
isInlineScriptLoaded variable to check if the inline script has been loaded.
The C# code in the header section sets the
isInlineScriptLoaded variable based on whether the inline script content is found in the
RenderedInlineScripts collection. The
RenderedInlineScripts collection contains the content of inline scripts that have already been rendered on the page. We use
ToString().Contains(inlineScript) to check if the
inlineScript content is present in the collection.
isInlineScriptLoaded variable to perform actions based on whether the inline script has been loaded or not.
Keep in mind that this approach only checks if the exact inline script content is present in the
RenderedInlineScripts collection. If the inline script content has changed or if there are variations in whitespace or other characters, the check may not work as expected. If you need to perform more advanced checks, you may need to use other techniques or consider using external scripts instead.