You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple PHP script to combine and minify multiple JS or CSS files passed via URI, inspired by [jsDelivr](https://www.jsdelivr.com/features/?utm_source=github.com&utm_medium=campaign&utm_content=button&utm_campaign=php-combine-scripts#combine).
8
+
A simple PHP script to combine and minify multiple JS or CSS files passed via URI, inspired by [jsDelivr](https://www.jsdelivr.com/features/?utm_source=github.com&utm_medium=referral&utm_content=link&utm_campaign=php-combine-scripts#combine).
9
9
10
10
## Setup
11
11
12
12
1. Clone or unzip the files to a directory off of your web root. For example, `/combine/`. Change to that directory.
13
13
1.`composer install`
14
-
1. Rename `.env-sample` to `.env`. Change the `COMBINE_BASEDIR` to match your web root.
14
+
1. Rename `.env-sample` to `.env`. Set the `COMBINE_BASEDIR` to the directory that will contain your JS/CSS files that you want to allow combining/minification for.
15
15
1. Configure your web server to rewrite URLs, as shown in the examples below. Change the `/combine/` and `/minify/` paths as desired.
For example, let's say that you set your `COMBINE_BASEDIR` to `/var/www/html/scipts/`. Withing this directory, you might have some JS or CSS libraries. We'll combine [Font Awesome](https://fontawesome.com/?utm_source=github.com&utm_medium=referral&utm_content=link&utm_campaign=php-combine-scripts) with the [v4 shims](https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4/?utm_source=github.com&utm_medium=referral&utm_content=link&utm_campaign=php-combine-scripts#shims) as an example, assuming that you have already [extracted them](https://github.com/FortAwesome/Font-Awesome/tree/master/css) to `/var/www/html/scipts/dist/css/`.
Of course, minification is not necessary for scripts that you already have minified versions for. It is merely an option for libraries/scripts that do not contain a minified version. If you have minified versions avaible, it is recommended to simply use the "combine" method as it consumes less system resources.
0 commit comments