Created
November 14, 2016 16:15
-
-
Save Antoinebr/f1ae25e582a03899f00eda13b4c9f855 to your computer and use it in GitHub Desktop.
server push in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function push_to_browser($as, $uri) { | |
| header('Link: ' . $uri . '; rel=preload; as=' . $as, false); | |
| } | |
| $assets = array( | |
| // enter the path enter the type of file (script / style / etc...) | |
| '<css/critical.css>' => 'style' | |
| ); | |
| array_walk( $assets, 'push_to_browser'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment