Download the PHP package johannschopplich/kirby-hashed-assets without Composer

On this page you can find all versions of the php package johannschopplich/kirby-hashed-assets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kirby-hashed-assets

Kirby Hashed Assets

Enhances Kirby's css() and js() helpers to support hashed filenames. Pass your normal paths (e.g. …main.js) – the plugin will lookup hashed assets and transform the path automatically (e.g. …main.20201226.js). That way you can even keep asset paths identical in development and production environment!

Key Features

Projects Using the Hashed Assets Plugin

Requirements

Installation

Download

Download and copy this repository to /site/plugins/kirby-hashed-assets.

Git Submodule

Composer

Usage

Automatic Hashing With manifest.json

For file hashing this plugin uses the hashup npm package.

hashup is a tiny CLI tool with two objectives in mind for your freshly build assets:

  1. Rename or rather hash (hence the name) the assets.
  2. Generate a manifest.json for them.

You don't even have to install it to your devDependencies, since npx will fetch it once on the fly. Add hashup to your build pipeline by adding it your package.json scripts (recommended), for example:

Now, pass asset paths to Kirby's asset helpers like you normally do:

If a corresponding hashed file is found in the manifest.json, it will be used and rendered.

For template-specific assets, use @template (instead of @auto):

[!WARNING] If no template file exists, https://example.com/@template will be echoed. This will lead to HTTP errors and blocked content since the requested file doesn't exist and the error page's HTML will be returned.

If you are unsure if a template file exists, use the following helpers:

They will echo a link tag, respectively script tag, only if a template file for current page's template is present.

Manual Hashing

For smaller websites you may prefer no build chain at all, but still want to utilize some form of asset hashing. In this use-case you can rename your files manually.

Take an imaginary main.js for example. Just include it like you normally would in one of your snippets:

Now rename the file in the format of main.{hash}.js. You may use the current date, e.g.: main.20201226.js, which will output:

Voilà, without changing the asset path the hashed file will be found and rendered in your template!

Hashed Filenames for Preloading Links

You can use the global hashedUrl() helper to lookup a file like you normally would with the css() or js() helpers. While the latter return a link or respectively script tag, the hashedUrl() helper will only return a URL which you can use in any context.

Since all evergreen browsers finally support JavaScript modules natively, you may prefer preloading modules:

License

Johann Schopplich


All versions of kirby-hashed-assets with dependencies

PHP Build Version
Package Version
Requires getkirby/composer-installer Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package johannschopplich/kirby-hashed-assets contains the following files

Loading the files please wait ....