SPFX Web parts not loading on load
We have observed that SPFX web parts functionality got changed in previous two days . Previously web parts used to load on the first load. Now the web parts are loading one after the other in the scroll. Can some one suggest here , is something which has changed in the previous one week?
Any suggestions or answers would be highly appreciated. Many Thanks
@VesaJuvonen @waldekmastykarz @mcmynn83
Same here, some web parts are only available after scrolling down the page. 1px down seems to be enough: document.querySelector('#s4-workspace').scrollTop += 1
Displaying modern web parts on classic site btw
Sorry for the delay - we have been working on optimizations to not fire the load event on webparts that are outside of the viewport in order to speed up page perf. Are you seeing errors when the webpart renders (or that the webpart doesn't render), or just that your onload isn't getting fired until you scroll into view?
@patmill No there are no errors once the web part is loaded . The issue is the second layer of the page has few web parts. In that scenario until the view port of the web parts which are there in the second layer are loading the web parts are seen blank, this makes the user experience bad. The user will think that there is no data in that particular area. This is happening in few devices only .This wont be an issue with the large screens.
@patmill is this something we can override? We have a particular scenario where content is dynamically shown/hidden, causing the web parts to load only after scrolling. It would be nice if this loading behavior can be changed in some way?
Checking if there's some new info? :)
any updates with this item? we're also experiencing some user experience confusion.
I would also like an update on this issue. Is there a way to override it and fire all the load events? Page performance is not as concerning for us at this point. Having half of the page being blank is much more of a concern.
Thanks
@UMAknow-Kien we had to write a script that basically jiggles the page up and down a pixel on load. less than ideal at this point but seems to be working for us until we hear word.
@UMAknow-Kien @kmartindale same here... added a script to move s4-workspace up and down.
Hi, this is a real issue for us. On modern pages, we observed these two problems:
-
We have several full-width web parts on top of a modern page. They therefore each have there own section (limitation to only a single web part in full-width section apparently). The sections seem to have a long height by themselves on load even if they collapse around the actual rendering of the containing web parts afterward. The effect is that only the first couple of web parts get rendered then collapsed and most the of page appear blank to the end user until they scroll. There is no easy way to add that kind of automatic scroll script in modern pages.
-
The other situation is that we have a very long FAQ web part that spans over several pages. A search bar automatically filters it. It seems that the web part gets rendered only after a certain proportion is visible, say 20%, which looks fine for the average web part. But for such a long web part, nothing gets displayed until a good deal of scrolling over a blank page! This completely breaks the user experience.
Is there any way to have more control over this behavior? @VesaJuvonen @waldekmastykarz @mcmynn83 @patmill
I managed to inject some script in the modern page, changing the scroll position successfully. However, the effect is simply to load the web parts within the specific viewport that I end in. I tried to scroll at the bottom and back up, but the render seems to happen after that, so it does not change anything. I also tried to scroll at the bottom, wait 5 seconds and go up, but then only what was in the viewport at rendering time has rendered and I ended back to a blank section that did not re-render. Argh!!!
Sample script used:
var canvas = document.getElementById('spPageCanvasContent');
var scrollRegion = canvas.parentElement.parentElement;
//scrollRegion.scrollTop +=300;
//scrollRegion.scrollTop =0;
var millisecondsToWait = 5000;
scrollRegion.scrollTop = canvas.scrollHeight;
setTimeout(function() {
scrollRegion.scrollTop = 200;
}, millisecondsToWait);
@sidjustsid @umaknow-francis @NickSevens @UMAknow-Kien @Jordy84 are you still experiencing this issue?
Yes, I did a quick check, but it seems different: the web part are now in a "loading" state, but never loads until I scroll down.
@umaknow-francis does it still not load after 30-60 seconds without scroll? (if so, do you see any errors in the console?)
You can send a copy of the logs by pressing Ctrl and F12 and on the "Trace" tab click "Export CSV".
I think the issue is not existing now. MS has just checked this as a test and reverted back. @patmill Could you please update on this?
Well, I checked again and definitely see the issue still. Before, it was just blank, but now we see the web part loading forever, yes more than 60 seconds, until I scroll down. See for yourself in this screenshot.

@umaknow-francis can you provide the trace logs for that page? (Ctrl and F12, then click on the "Trace" tab, then click "Export CSV") Also do you see any errors from the browser console?
Just to confirm, you're observing the webpart does not load until you scroll down?
@umaknow-francis To add, this perf optimization was turned off (loading only after 20% of webpart is in viewport)
Closing as this optimization was removed.
I confirm that the issue is gone with the "optimization" now removed. Very happy that it works well again!