sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

SPFX Web parts not loading on load

Open sidjustsid opened this issue 9 years ago • 37 comments

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

sidjustsid avatar Jul 18 '17 07:07 sidjustsid

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

Jordy84 avatar Jul 25 '17 11:07 Jordy84

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 avatar Jul 27 '17 17:07 patmill

@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.

sidjustsid avatar Jul 28 '17 05:07 sidjustsid

@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?

nse7ens avatar Aug 31 '17 08:08 nse7ens

Checking if there's some new info? :)

nse7ens avatar Oct 31 '17 15:10 nse7ens

any updates with this item? we're also experiencing some user experience confusion.

kmartindale avatar Jan 29 '18 14:01 kmartindale

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

Tran-Kien avatar Feb 16 '18 16:02 Tran-Kien

@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.

kmartindale avatar Feb 16 '18 16:02 kmartindale

@UMAknow-Kien @kmartindale same here... added a script to move s4-workspace up and down.

nse7ens avatar Feb 16 '18 16:02 nse7ens

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

umaknow-francis avatar Feb 16 '18 16:02 umaknow-francis

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);

umaknow-francis avatar Feb 16 '18 19:02 umaknow-francis

@sidjustsid @umaknow-francis @NickSevens @UMAknow-Kien @Jordy84 are you still experiencing this issue?

dgaeta avatar Feb 23 '18 21:02 dgaeta

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 avatar Feb 23 '18 21:02 umaknow-francis

@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".

dgaeta avatar Feb 23 '18 22:02 dgaeta

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?

sidjustsid avatar Feb 24 '18 07:02 sidjustsid

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. web parts not loading

umaknow-francis avatar Feb 24 '18 20:02 umaknow-francis

@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?

dgaeta avatar Mar 26 '18 18:03 dgaeta

@umaknow-francis To add, this perf optimization was turned off (loading only after 20% of webpart is in viewport)

dgaeta avatar Mar 26 '18 19:03 dgaeta

Closing as this optimization was removed.

dgaeta avatar Mar 27 '18 00:03 dgaeta

I confirm that the issue is gone with the "optimization" now removed. Very happy that it works well again!

umaknow-francis avatar Mar 29 '18 19:03 umaknow-francis