[wp-hackers] Optimize wp_register_script and, wp_enqueue_script functions

zhaiziming at gmail.com zhaiziming at gmail.com
Mon Jan 30 05:01:05 UTC 2012


Just check the wordpress initialization process and drew several flow 
charts of it. I believe 'template_redirect' is called after 
$wp->parse_request. And there are a lot of other action hooks before 
these two steps that can be used. Please check the flow charts 
<http://www.zhaiziming.com/zZ/2012/completely-wordpress-initialization-flow-chart-1/> 
I drew.
Since shortcodes can support inline script enqueue. I am fine with it 
for now. Thank you for your comment.

Ziming

On 1/26/2012 4:57 PM, Mike Schinkel wrote:
> 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
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list