User tests: Successful: Unsuccessful:
To support HTTP preloading, a new PreloadManager service is introduced and hooked into JDocument to allow developers to register preload links.
In JHtmlJquery, change the line actually loading the jQuery file to read this:
JHtml::_('script', 'vendor/jquery/jquery.min.js', array('version' => 'auto', 'relative' => true, 'detectDebug' => $debug, 'preload' => array('preload')));With this patch applied, the base response should have a Link:</media/vendor/jquery/js/jquery.min.js>; rel="preload" header.
To use this API to preload stylesheet and JavaScript assets through either JHtml or JDocument directly, a new preload key is added to the $options array.  This is an array of the preload types that should be used for an item.  So 'preload' => array('preload') would only add the resource with rel="preload" and 'preload' => array('preload', 'prefetch') would add a value for both rel="preload" and rel="prefetch".
The Link header is computed as the last step of JDocument::render(), meaning this happens after the onBeforeCompileHead event has been run and the <head> element generated, but will be before the onAfterRender event.  So this is hookable until pretty late in the request, but afterwards you would need to get the header and manually edit that.
The preload support is not limited to stylesheets and JavaScripts loaded through JDocument or JHtml.  In fact, there is a new JDocument::getPreloadManager() method which will fetch the new PreloadManager service and through this you can add preloading requests for any supported reference type.
JDocument will support any Joomla\CMS\Document\PreloadManagerInterface implementation, allowing developers to create their own objects if desired.  This can be injected through the options array or through the public set method.
Internally, the default Joomla\CMS\Document\PreloadManager implementation uses Fig\Link\GenericLinkProvider as the internal link provider but any provider implementing PSR-13's Psr\Link\EvolvableLinkProviderInterface can be set using the preload manager's  setLinkProvider method.
Lastly, I am only doing this for 4.0 because all of the code required to make an API supporting this is already written elsewhere (Symfony's new WebLink component and the PHP-FIG's Link utilities package) and the dependencies aren't PHP 5.3 compatible.  Sure, we can write all of the logic ourselves and get it into 3.x, but frankly I'd rather not do the work to sort out how to internally track these resources or build the Link header with the correct structure.
JDocument| Status | New | ⇒ | Pending | 
| Category | ⇒ | Repository External Library Libraries | 
| Labels | Added: 
?
? | ||
 
                 
                Rebased
| Milestone | Added: | ||
| Milestone | Added: | ||
| Status | Pending | ⇒ | Fixed in Code Base | 
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-06-18 21:14:56 | 
| Closed_By | ⇒ | wilsonge | |
| Labels | Added: 
? | ||
Can you fix conflicts please