[wp-hackers] Optimize wp_register_script and, wp_enqueue_script functions
Mike Schinkel
mikeschinkel at newclarity.net
Fri Jan 27 00:57:32 UTC 2012
On Jan 26, 2012, at 1:18 PM, zhaiziming at gmail.com wrote:
> Would be better to let plugin authors to do this, and bind (or register) js files to specific pages?
One of the problems with that idea is that WordPress doesn't currently have a simplistic way to identify a specific "page." Each resultant "page" is represented by an array elements in $wp->query_vars which are set by $wp->parse_request() when it attempts to match the current URL with the URL rewrite rules to determine those values. And $wp->query_vars can also contain elements that don't effect URL routing so you can't just URL encode that array to get a unique "page" identifier.
Plus it's also possible to serve pages via the 'template_redirect' hook so you can't even depend on the results of $wp->parse_request().
So unless and until WordPress core were to standardize some method of specifying "pages" via a simple identifier (which I would be excited to see happen) then your idea is a nice one but not realistic. FWIW.
-Mike
More information about the wp-hackers
mailing list