How to Inject your Custom JavaScript in Modern Pages on Page Load

This SPFx functionality helps to inject your custom JavaScript file in your modern site pages on page load. [code lang=”c”] export default class MySPFXApplicationCustomizer extends BaseApplicationCustomizer<IMySPFXApplicationCustomizerProperties> { private _customJsUrl: string = “https://sharepointdomain.net/scripts/MyCustonScript.js”; @override public onInit(): Promise<void> { let scriptTag: HTMLScriptElement = document.createElement(“script”); scriptTag.src = this._customJsUrl; scriptTag.type = “text/javascript”; document.getElementsByTagName(“head”)[0].appendChild(scriptTag); return Promise.resolve<void>(); } } [/code] This solution is brought to you […]