Opened 14 years ago
Closed 14 years ago
#16585 closed enhancement (wontfix)
Proposed changes to wp enqueueing and shortcode handling
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 3.1 |
Component: | General | Keywords: | dev-feedback needs-patch needs-codex |
Focuses: | Cc: |
Description
Currently, the only way for a programmer to avoid loading their scripts/css on every page is to either peek through the_content() for their shortcode and enqueue accordingly, or to use their shortcode handler to set a boolean for doing a conditional script print after partially loading a page. While this is certainly feasible, it's largely unused and the majority of plugins overload css and js unnecessarily.
I propose that instead of operating under the expectation that all programmers do this, we instead implement a mechanism to do this solely through wp_enqueue_script and wp_enqueue_style.
This can be achieved by storing a list of used shortcode tags within a pages meta, likely while saving a post or page, that can later be used as a conditional check with, among others, wp_enqueue_script and wp_enqueue_style.
A new optional parameter would be then added to wp_enqueue_script and wp_enqueue_style that would check said meta, or potentially other meta, and conditionally load, without the requirement of any further coding.
Change History (3)
#3
@
14 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
We had a lengthy discussion in IRC, which can be summarised as follows:
- a solution for Core would need to avoid DB writes on the front-end and bulk re-processing of posts on plugin activation (we couldn't find said solution)
- most shortcodes shouldn't have heavy JS/CSS anyway, so it shouldn't be such a big deal if they're loaded on all pages
Big -1. As described in IRC: