Title: Adding preload to the header
Last modified: September 1, 2016

---

# Adding preload to the header

 *  [archimedes.trajano](https://wordpress.org/support/users/archimedestrajano/)
 * (@archimedestrajano)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/adding-preload-to-the-header/)
 * I’m trying to see where in the code I can add something like this
 *     ```
       header(
         sprintf(
           'Link: <%s>; rel=preload; as=%s',
              $cached_css_critical, 'style'
         )
       )
       header(
         sprintf(
           'Link: <%s>; rel=preload; as=%s',
              $cached_js, 'script'
         )
       )
       header(
         sprintf(
           'Link: <%s>; rel=preload; as=%s',
              $cached_css, 'style'
         )
       )
       ```
   
 * to have it preload from the header. [https://blog.cloudflare.com/using-http-2-server-push-with-php/](https://blog.cloudflare.com/using-http-2-server-push-with-php/)
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/adding-preload-to-the-header/#post-7681408)
 * you’re ahead of the curve archimedes.trajano, this is [being looked into already (feel free to join the discussion)](https://github.com/futtta/autoptimize/issues/49)
   and should arrive later this year (but not in [the upcoming 2.1](https://wordpress.org/support/topic/preparing-for-autoptimize-210-wanna-test?replies=32)
   yet).
 * you should however be able to concoct something by hooking into AO’s `autoptimize_html_after_minify`
   filter to capture the optimized HTML (including references to CSS/JS), parse 
   out the autoptimize-links and hook into [wordpress’ `send_headers`](https://codex.wordpress.org/Plugin_API/Action_Reference/send_headers)
   to add the links?
 * one remark though; critical css is inlined in the HTML, so preloading it would
   make little sense.
 * hope this helps,
    frank

Viewing 1 replies (of 1 total)

The topic ‘Adding preload to the header’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

## Tags

 * [HTTP/2](https://wordpress.org/support/topic-tag/http2/)

 * 1 reply
 * 2 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/adding-preload-to-the-header/#post-7681408)
 * Status: not resolved