2017 © Pedro Peláez
 

library asset

Caches and delivers assets of every sort, from any location, with hands-off versioning. Manipulates images on-the-fly. Minifies and combines (on-demand) css and javascript files.

image

bootpress/asset

Caches and delivers assets of every sort, from any location, with hands-off versioning. Manipulates images on-the-fly. Minifies and combines (on-demand) css and javascript files.

  • Friday, January 20, 2017
  • by BootPress
  • Repository
  • 1 Watchers
  • 0 Stars
  • 958 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

use BootPress\Asset\Component as Asset;

Packagist ![License MIT][badge-license] HHVM Tested ![PHP 7 Supported][badge-php] Build Status ![Code Climate][badge-code-climate] Test Coverage, (*1)

Asset::cached() is a one-stop method for all of your asset caching needs. This should be the first thing that you call. It checks to see if the page is looking for a cached asset. If it is, then it will return a response that you can $page->send(). If not, then just continue on your merry way. When you $page->display() your html, it will look for all of your assets, and convert them to cached urls., (*2)

  • If an asset is found we give it a unique (5 character) id that then becomes the "folder", and we add the basename() to the end for reference / seo sakes.
    • http://example.com/page/dir/bootstrap.css will become http://example.com/...../bootstrap.css where 'bootstrap.css' means nothing, and ..... is the actual asset location.
    • 60 alphanumeric characters (no 0's) ^ 5 (character length) gives 777,600,000 possible combinations.
  • If a #fragment is located immediately after the asset, we'll remove the fragment and ...
    • If it is a .css or .js file then we will combine them together so that http://example.com/page/dir/bootstrap.css#../default.css#user/custom.css will become http://example.com/.....0.....0...../bootstrap-default-custom.css and we'll minify and serve the /page/dir/bootstrap.css, /page/default.css, and /page/dir/user/custom.css files all at once.
    • Otherwise we'll replace the name with it ie. http://example.com/page/dir/image.jpg#seo will become http://example.com/...../seo.jpg
  • If you add a query string to images, we'll remove and save it with the filename ie. http://example.com/page/dir/image.jpg?w=150#seo will become http://example.com/...../seo.jpg only ..... will be different from the previous example, and the image.jpg's width will be 150 pixels.
  • The filemtime() is saved so that when an asset changes, we can give it a new unique filename that the browser will then come looking for and cache all over again.
    • This allows us to tell browsers to never come looking for the asset again, because it will never change.
    • There is no better way to make your pages load any faster than this.

Installation

Add the following to your composer.json file., (*3)

``` bash { "require ": { "bootpress/asset": "^1.0" } }, (*4)


## Example Usage ``` php <?php use BootPress\Page\Component as Page; use BootPress\Asset\Component as Asset; $page = Page::html(); if ($asset = Asset::cached('assets')) { $page->send($asset); } $html = $page->display('

Content, (*5)

'); $page->send(Asset::dispatch('html', $html));

License

The MIT License (MIT). Please see License File for more information., (*6)

The Versions

20/01 2017

dev-master

9999999-dev https://www.bootpress.org/components/asset.html

Caches and delivers assets of every sort, from any location, with hands-off versioning. Manipulates images on-the-fly. Minifies and combines (on-demand) css and javascript files.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

css javascript assets image manipulation glide minify bootpress

20/01 2017

v1.0.1

1.0.1.0 https://www.bootpress.org/components/asset.html

Caches and delivers assets of every sort, from any location, with hands-off versioning. Manipulates images on-the-fly. Minifies and combines (on-demand) css and javascript files.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

css javascript assets image manipulation glide minify bootpress

28/09 2016

v1.0

1.0.0.0

Caches and delivers assets of every sort, from any location, with hands-off versioning. Manipulates images on-the-fly. Minifies and combines (on-demand) css and javascript files.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

css javascript assets image manipulation glide minify bootpress