0

I have an app that loads in JavaScript and CSS files when it initializes; when the user navigates to a different subsite that has different files to load in, the app triggers again and loads in the new JavaScript and CSS files. The app uses the method SPComponentLoader.loadScript/loadCss from the package @microsoft/sp-loader to load in the CSS and JavaScript.

The issue that I am facing is the old JavaScript is still loaded in, even though the app removes the related html DOM elements (script elements with src attribute pointing at the JavaScript file URL).

What I am looking for, is there a way to remove the old JavaScript that is still loaded in even though the DOM element is removed?

Notes:

  • I will not necessarily have control of the JavaScript files and their contents
  • This is for modern SharePoint Online.
  • Vanilla JavaScript is preferred or capabilities afforded by SharePoint apps
  • Would like to avoid a full page reload

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.