MyBB Community Forums

Full Version: {$stylesheets}
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to output the contents of $stylesheets directly in the <head> section of headerinclude.

With a single stylesheet it's fairly easy to put:

<style>
<?php
      ob_start();
      include('stylesheet.css');
      $template = ob_get_clean();
      print($template);
?>
</style>

Any tips on how i can get the individual stylesheets of $stylesheets to print in the same manner?
You'd probably need to hook into global_intermediate and explode the $stylesheets string, get the path and include the contents.

Out of interest, why are you trying to output them directly? It'll mean far larger page transfers and no browser caching of assets.
(07-05-2016, 12:29 PM)Matt. Wrote: [ -> ]You'd probably need to hook into global_intermediate and explode the $stylesheets string, get the path and include the contents.

Out of interest, why are you trying to output them directly? It'll mean far larger page transfers and no browser caching of assets.

Thanks for the reply, main reason is to try to eliminate render-blocking JavaScript and CSS in above-the-fold content. If I am not mistaken it will also reduce the number of network requests, which I hope will improve my server response time.
Okay, can understand for the render-blocking CSS, but when doing that it's normally recommended to only have core CSS loaded inline, and not much of it, rather than the entirety oft he site's styles. It may reduce HTTP requests slightly but if asset requests are having an affect on your server speed, you've got bigger problems. You might want to look into Cloudflare as that has asset caching which may be what you want? It would also probably serve the files up quicker than your server anyway.
No not a problem as such, just looking to optimise. Another option could be to combine stylesheets into say global.css incl stylesheets introduced by plugins, so that there is only one request.