﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
16343,"API for WP_Scripts: allow async loading, version checks",jltallon,,"When developping a theme lately, I have found myself in the need of directly accesing the internals of the WP_Scripts class. I feel the funcionality I need might well help other developers.


Use cases:

1.- Asynchronously load a (JS) script loaded by a/another plugin

  When loading a certain page, we needed to asynchronously load some (relatively heavy) scripts which are only seldom used. In order to keep page rendering fast, we only load them on demand, after the page frame has been rendered.
  In order to avoid having to bundle (potentially conflicting versions) scripts in every plugin and prevent duplicate loading, I suggest adding an API which would enable querying the source (as used by 'scripts-loader') 


2.- Version checks for loaded scripts

  For high-performance sites, it might be useful to load a Google (or some other CDN) -provided jQuery et al ---which the user might already have cached--- instead of the bundled one, as long as it is the same version.

 Code example:
   $ver = $wp_scripts->version('jquery');
   wp_unregister_script('jquery');
   wp_register_script('jquery',""http://ajax.googleapis.com/jquery/$ver/jquery.min.js"",false,$ver);


(needs discussion)



I can provide the code (or the patch against Core) when the solution is decided (or soonish, if a proof-of-concept is needed)
If WP 3.2 is going to finally be PHP 5.2+, I'd rather basically rewrite WP_Scripts (and/or WP_Dependencies).
",enhancement,assigned,normal,Future Release,Performance,,minor,,needs-patch,jltallon mikeschinkel@…
