I’ve been working on a website and I’m taking performance very seriously, considering mobile networks in Brazil are slow at times. Right now the home page is below 150kb and loads really fast (I’m caching pages with Memcached and gzipping with Nginx).
<!-- template/search.php --> <?php snippet('footer', ['scripts' => [ 'assets/js/vendors.js', 'assets/js/search.js', ]]) ?>
<!-- snippet/footer.php --> <?php echo js('assets/js/main.js') ?> <!-- loads on every page --> <?php if (isset($scripts)) echo js($scripts) ?> </body> </html>
The same principle can be applied to stylesheets.