PressForward / pressforward

PressForward is a free plugin that provides an editorial workflow for content aggregation and curation within the WordPress dashboard. It is designed for bloggers and editorial teams who wish to collect, discuss, and share content from a variety of sources on the open web.
GNU Affero General Public License v3.0
120 stars 21 forks source link

Overhaul script/style registration and enqueuing process #1159

Closed boonebgorges closed 9 months ago

boonebgorges commented 1 year ago

PressForward currently loads many of its scripts and styles using its AssetsProvider system, which internally uses the Register toolset in Jaxion. The Jaxion system, and PF's technique for leveraging it, have some limitations:

The current system feels overengineered, raising the bar for developer experience (it's harder to reason about and keep track of), which leads to sacrifices that reduce performance (like PF's just-load-everything strategy).

I'd like to move toward a system that works like this:

boonebgorges commented 12 months ago

I've got a version of this up and running. I made the primary change at the level of Intraxia\Jaxion\Assets\Register. Instead of register() building an internal queue, and then using that queue to enqueue scripts based on the 'condition' argument, register() now calls wp_register_script(). Assets are then enqueued on an as-needed basis.

I've made very little attempt at this point to pick apart unneeded dependency chains. That being said, I can already see a decrease of 3-5 scripts/styles being added by PF on most pages in the Dashboard. This includes assets that were needlessly loaded globally, as well as those that were loaded on all PF pages but are only needed in a handful of places. I'll continue to clean these areas up as it's convenient to do so.

boonebgorges commented 9 months ago

I'll close this ticket for now, but continue in future versions to look for places where I can improve the relationship between dependent scripts.