Make WordPress Core

Opened 2 years ago

Last modified 8 months ago

#55344 accepted feature request

Resources for hidden widgets are loaded on WP dashboard

Reported by: josklever's profile josklever Owned by: adamsilverstein's profile adamsilverstein
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Administration Keywords: needs-patch
Focuses: javascript Cc:

Description

When plugins are placing widgets on the WordPress dashboard and these are hidden via the Screen Options the resources of those widgets are still loaded.

In the Sources tab of the browser console this can easily be checked. I've noticed this with multiple plugins, so it looks like a core bug.

It would save resources and increase performance of the dashboard if hidden items are not loaded.

I've asked in the #performance Slack channel, where I was asked to create a ticket to report this as a bug.

Change History (10)

#1 @adamsilverstein
2 years ago

  • Keywords needs-patch added
  • Owner set to adamsilverstein
  • Status changed from new to accepted

Hey @josklever - thanks for reporting this issue. I can confirm that the screen options controls don't do anything to alter loading of associated scripts. Guessing this has been a bug for a long time, since the Dashboard was introduced.

#2 @josklever
2 years ago

In addition there's also a closed state of a dashboard widget. In that case the content doesn't need to be rendered until it's opened. And opened widgets that are below the fold, might even be loaded only after scrolling with lazy loading.

This ticket was mentioned in Slack in #core by josklever. View the logs.


2 years ago

This ticket was mentioned in Slack in #core by josklever. View the logs.


2 years ago

This ticket was mentioned in Slack in #core by josklever. View the logs.


17 months ago

#6 @sabernhardt
17 months ago

  • Focuses javascript added
  • Milestone changed from Awaiting Review to Future Release
  • Version 5.9.1 deleted

#7 @ramon fincken
11 months ago

Now this is interesting.

I agree with you Jos that is is at the very least "strange" that those items are loaded.

However on the other hand it is for many many years ( which is not a good reason however to NOT take up this ticket ) the case that dashboard widgets are instantly shown/hidden with the screen options.

Applying what you mention would either ( in my backender-opinion ) require:
A) fully reload the dashboard page
or
B) use AJAX/json to load widgets.

In my experience loading javascript that was not present before trigging XHR responses is very very tricky. So that would ( to assure 100% working guarantee of all widgets out there ) only leave option A, am I correct on this ?

That means that you can only instant hide a currently shown widget just like it is now, but you _cannot_ instantly show a previously hidden widget as you will need a full page reload.

#8 @mukesh27
10 months ago

  • Focuses performance removed

This ticket is not performance related so I am removing the tag.

#9 @ramon fincken
10 months ago

I beg to differ with you on this. Yes it is minor, but still it impacts CPU (server and client) so yes -> performance.

#10 @rajinsharwar
8 months ago

  • Type changed from defect (bug) to feature request

As @adamsilverstein mentioned, the Screen Options hides the widgets using JS, and doesn't alter the loading of any JS scripts, or styles. This is how the widget hiding feature is implemented.

Note: See TracTickets for help on using tickets.