Make WordPress Core

Opened 13 years ago

Closed 9 years ago

Last modified 9 years ago

#15381 closed enhancement (maybelater)

Rework WP_Scripts to support named groups

Reported by: westi's profile westi Owned by: westi's profile westi
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: needs-patch westi-likes
Focuses: Cc:

Description

Currently WP_Scripts has some "special" code for splitting things across header and footer and concatenating core scripts.

I would like to change it to support the following:

  • Named Groups - so we can have header, footer, ...
  • L10N awareness - so we can auto output the l10n.js file first if we need it - XRef #15124
  • Concatenation opt-out
  • Concatentaion opt-in for plugins.

I was working on this for #15124 until it became apparent that it wasn't right to do it for 3.1 - not enough time to fully test.

Change History (8)

#1 @demetris
13 years ago

  • Cc dkikizas@… added

#2 @azizur
13 years ago

  • Cc azizur added

#3 follow-up: @westi
13 years ago

To think about: http://headjs.com/

#4 in reply to: ↑ 3 @andy
13 years ago

Replying to westi:

To think about: http://headjs.com/

I spent an evening hacking together a plugin that extends WP_Scripts to use head.js rather than individual script tags. It worked in the sense that it caused the page to load without blocking for the scripts. However, it broke several of the most basic scripted function such as the collapsing admin menus.

We commonly use inline scripts with the assumption that dependencies are already loaded. When loading scripts with head.js, you can't assume this. The fix is simple: wrap the script in a head.js call that delays execution until the dependency is fulfilled. You can still use inline scripts; you just have to take this little extra step (for which we could build helpers into WP_Scripts/WP_Dependencies).

<script>
// call a function assuming jQuery Tools is loaded
jQuery(".tip").tooltip();
</script>
<script>
// call a function immediately after jQuery Tools is loaded
head.ready("tools", function() {
   $(".tip").tooltip();
});
</script>

It is possible to use script concatenation with head.js but I don't think it has facilities for one script to fulfill multiple dependencies. I have created an issue on the head.js project on GitHub.

#5 @westi
13 years ago

  • Keywords westi-likes added; 3.2-early removed
  • Type changed from defect (bug) to enhancement

Removing 3.2-early tag this didn't make the feature cut for 3.2

#6 @nacin
10 years ago

  • Component changed from JavaScript to Script Loader

#7 @chriscct7
9 years ago

  • Keywords needs-patch added; westi-likes removed
  • Milestone Future Release deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Closing as maybelater. Complete lack of interest on the feature on the ticket over the last 5 years. Feel free to reopen when more interest re-emerges (particularly if there's a patch).

#8 @DrewAPicture
9 years ago

  • Keywords westi-likes added

Legit tag.

Note: See TracTickets for help on using tickets.