Skip to content

Instantly share code, notes, and snippets.

@Antoinebr
Created November 14, 2016 16:15
Show Gist options
  • Select an option

  • Save Antoinebr/f1ae25e582a03899f00eda13b4c9f855 to your computer and use it in GitHub Desktop.

Select an option

Save Antoinebr/f1ae25e582a03899f00eda13b4c9f855 to your computer and use it in GitHub Desktop.
server push in PHP
<?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