I am dynamically loading external CSS from a separate source using JavaScript, which updates the design of my website.
var link = document.createElement( "script" );
link.src = "http://externalsourcee.com/page/js/generate?token=I-css76theme";
document.getElementsByTagName( "head" )[0].appendChild( link );
The issue I am facing is that the updated CSS design on my webpage appears after the initial display, causing lag for the user.
My question is: How can I ensure that the user does not see any changes happening, and only sees the new design once the page has fully loaded? Alternatively, if some lag is unavoidable, how can I implement a loading screen to show progress while the CSS updates?
Note: I am unable to directly edit the HTML file, so changes must be made through externally loaded JavaScript.