Linked Questions

Popular Questions

Identifying whether a script has executed

Asked by At

If a script tag is inserted using HTMLElement.innerHTML it's not executed. Is there a way to identify, by looking at the HTMLScriptElement, that it has never been executed?

Longer context: a React app with server side rendering uses React's dangerouslySetInnerHTML to inject dynamic content which may include <script> tags. When server side rendered these scripts run, when client side rendered they do not. I'd like to use lifecycle hooks to inspect execute the scripts client side without executing the ones that were executed due to server side rendering already.

Related Questions