WordPress.org

Make WordPress Core

Opened 19 months ago

Closed 19 months ago

Last modified 18 months ago

#43384 closed feature request (invalid)

wp_enqueue_script:require authors to document these in the readme.txt file or style.css for example

Reported by: design_dolphin Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords:
Focuses: Cc:

Description

A. Problem description:
Too often finding a script not to run on certain locations is too cumbersome. wp_enqueue_script becomes a hunt for where a script is coming from, and then how to dequeue (under which name for example) it can be a time costing adventure. Still some authors don't use the wp_enqueue_script but a different way of declaring. Getting into (de)registering a script as well, and when to choose which if you want to offload a script, it's time consuming. This adds to development cost and time.

B. Real world example:
Take LazyLoad, quite a number of plugin authors are using this now (including JetPack), and so one can have multiple LazyLoad scripts to dequeue. Add in caching on multiple levels, and it is quite the mess to clean up.

C. Performance Influence
I have some concerns about how many scripts/styles get loaded all over the place, as a basic design premise. Loading scripts and styles only where they are needed can result in significant benefits such as improved load times. This can be done manually, and there are some plugins working with and on this as well.

D. Proposed solutions:

  1. Make it best practices/requirement to document scripts/styles enqueed in the plugin/theme read me file, or at the top of the style.css for example for css (where would JS go?)
  2. Check automatically plugins/themes hosted on wordpress.org whether they comply or not and refuse to publish until they do. With a transition period for existing plugins. (This doesn't solve plugins/themes hosted elsewhere)

Change History (3)

#1 @design_dolphin
19 months ago

  • Summary changed from wp_enqueue_script:require authors to document these in the read.me file or style.css for example to wp_enqueue_script:require authors to document these in the readme.txt file or style.css for example

#2 @danieltj
19 months ago

  • Focuses javascript template performance coding-standards removed
  • Resolution set to invalid
  • Status changed from new to closed

Hi, welcome to Core Trac! :)

This site is for WordPress Core, anything related to the plugin directory is more Meta Trac territory however this isn't something that really fits into a Meta issue because it comes down to how plugin authors build their plugins.

Plugins in general should allow lazy loading to be turned off rather than forcing it on, Jetpack gives people a setting for this making it optional. The easiest thing to do is to just search for wp_enqueue_script in the new plugin files and then dequeuing the ones you don't want.

#3 @ocean90
18 months ago

  • Component changed from Administration to Script Loader
  • Milestone Awaiting Review deleted
  • Version trunk deleted
Note: See TracTickets for help on using tickets.