0

I'm trying to inject a script into the lightning page by adding the JS Script into the pagebut i'm not able to see any Error or script in the page from Locker Compatibility HTMLScriptElement element is Supported https://developer.salesforce.com/docs/component-library/tools/locker-service-viewer

i'm using the following Script to append Script Element into the page

                var script = document.createElement("script");
                script.type = "text/javascript";
                script.text = "Console.log("Test Create element Script");
                document.body.appendChild(script);

When the lightning locker is off Script work fine

Q: is there a workaround to add HTMLScriptElement into lightning page with lightning locker ON?

2

If you were allowed to inject a script tag, you'd be able to circumvent Locker Service. For this reason, you're not allowed to do this. Use ltng:require or loadScript to load scripts for use in your components.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.