{"id":13560079,"url":"https://github.com/slav123/CodeIgniter-minify","last_synced_at":"2025-04-03T15:31:32.913Z","repository":{"id":43140239,"uuid":"1977514","full_name":"slav123/CodeIgniter-minify","owner":"slav123","description":"CodeIgniter minify library CSS and JavaScript compression on the fly","archived":false,"fork":false,"pushed_at":"2023-03-08T12:33:51.000Z","size":189,"stargazers_count":226,"open_issues_count":2,"forks_count":87,"subscribers_count":33,"default_branch":"master","last_synced_at":"2024-02-15T11:35:33.355Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slav123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-06-30T10:52:05.000Z","updated_at":"2024-08-01T13:15:41.313Z","dependencies_parsed_at":"2024-08-01T13:15:36.794Z","dependency_job_id":null,"html_url":"https://github.com/slav123/CodeIgniter-minify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slav123%2FCodeIgniter-minify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slav123%2FCodeIgniter-minify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slav123%2FCodeIgniter-minify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slav123%2FCodeIgniter-minify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slav123","download_url":"https://codeload.github.com/slav123/CodeIgniter-minify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247027940,"owners_count":20871625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:00:37.283Z","updated_at":"2025-04-03T15:31:27.884Z","avatar_url":"https://github.com/slav123.png","language":"PHP","readme":"# CodeIgniter - minify [![Build Status](https://travis-ci.org/slav123/CodeIgniter-minify.svg?branch=master)](https://travis-ci.org/slav123/CodeIgniter-minify)\n\nSimple CodeIgniter library to compress **CSS and JavaScript** files on the fly.\n\nLibrary is based on few other scripts like \u003chttp://code.google.com/p/minify/\u003e \nor \u003chttps://code.google.com/p/cssmin\u003e to minify CSS and it uses\n[Google Closure compiler](https://developers.google.com/closure/compiler/) to \ncompress JavaScript\n\n## Installation\nJust put `Minify.php` file in libraries path, and create `minify.php` config file on config directory.\n\n## Using the library\n\n#### Configure the library:\nAll directories needs to be writable. Next you can set your own values for config file.\n\n```php\n// enable/disable library (default value: 'TRUE')\n$config['enabled'] = TRUE;\n\n// output path where the compiled files will be stored (default value: 'assets')\n$config['assets_dir'] = 'assets';\n\n// optional - path where the compiled css files will be stored (default value: '' - for backward compatibility)\n$config['assets_dir_css'] = ''; \n\n// optional - path where the compiled js files will be stored (default value: '' - for backward compatibility)\n$config['assets_dir_js'] = '';     \n\n// optional - handy when your assets are in a different domain than main website (default value: '')\n$config['base_url'] = '';\n\n// where to look for css files (default value: 'assets/css')\n$config['css_dir'] = 'assets/css';\n\n// where to look for js files (default value: 'assets/js')\n$config['js_dir'] = 'assets/js';\n\n// default file name for css (default value: 'style.css')\n$config['css_file'] = 'styles.css';\n\n// default file name for js (default value: 'scripts.js')\n$config['js_file'] = 'scripts.js';\n\n// default tag for css (default value: '\u003clink href=\"%s\" rel=\"stylesheet\" type=\"text/css\" /\u003e')\n$config['css_tag'] = '\u003clink href=\"%s\" rel=\"stylesheet\" type=\"text/css\" /\u003e';\n\n// default tag for js (default value: '\u003cscript type=\"text/javascript\" src=\"%s\"\u003e\u003c/script\u003e')\n$config['js_tag'] = '\u003cscript type=\"text/javascript\" src=\"%s\"\u003e\u003c/script\u003e';\n\n// use html tags on output and return as a string (default value: 'TRUE')\n// if html_tags === FALSE - array with links to assets is returned\n$config['html_tags'] = TRUE;\n\n// use automatic file names (default value: 'FALSE')\n$config['auto_names'] = FALSE;\n\n// use to enable versioning your assets (default value: 'FALSE')\n$config['versioning'] = FALSE;\n\n// automatically deploy when there are any changes in files (default value: 'TRUE')\n$config['deploy_on_change'] = TRUE;\n\n// compress files or not (default value: 'TRUE')\n$config['compress'] = TRUE;\n\n// compression engine setting (default values: 'minify' and 'closurecompiler')\n$config['compression_engine'] = array(\n\t'css' =\u003e 'minify', // minify || cssmin\n\t'js'  =\u003e 'closurecompiler' // closurecompiler || jsmin || jsminplus\n);\n\n// when you use closurecompiler as compression engine you can choose compression level (default value: 'SIMPLE_OPTIMIZATIONS')\n// avaliable options: \"WHITESPACE_ONLY\", \"SIMPLE_OPTIMIZATIONS\" or \"ADVANCED_OPTIMIZATIONS\"\n$config['closurecompiler']['compilation_level'] = 'SIMPLE_OPTIMIZATIONS';\n```\n\n#### Available engines\n* CSS - `minify` or `cssmin` - both of them are local, just try out which one is better for you,\n* JS - `closurecompiler` makes API call to external server, it's slower then regular inline engine, but it's super efficient with compression, `jsmin` and `jsminplus` are local\n\n#### Run the library\nIn the controller:\n```php\n// load the library\n$this-\u003eload-\u003elibrary('minify');\n// or load and assign custom config (will override values from config file)\n$this-\u003eload-\u003elibrary('minify', $config);\n// by default library's functionality is enabled, but in some cases you would like to return\n// assets without compilation and compression - when debugging or in development environment\n// in that case you can use config variable to disable it\n$config['enabled'] = FALSE;\n// or\n$this-\u003eminify-\u003eenabled = FALSE;\n\n```\nIn controller or view:\t\n```php\n// set css files - you can use array or string with commas\n// when using this method, you replaces previously added files\n$this-\u003eminify-\u003ecss(array('reset.css', 'style.css', 'tinybox.css'));\n$this-\u003eminify-\u003ecss('reset.css, style.css, tinybox.css');\n\n// add css files - you can use array or string with commas\n// when using this method, you're adding new files to previous ones\n$this-\u003eminify-\u003eadd_css(array('reset.css'))-\u003eadd_css('style.css, tinybox.css');\n\n// set js files - you can use array or string with commas\n// when using this method, you replaces previously added files\n$this-\u003eminify-\u003ejs(array('html5.js', 'main.js'));\n$this-\u003eminify-\u003ejs('html5.js, main.js');\n\n// set js files - you can use array or string with commas\n// when using this method, you're adding new files to previous ones\n$this-\u003eminify-\u003eadd_js(array('html5.js'))-\u003eadd_js('main.js');\n\n// with methods: css(), js(), add_css() and add_js()\n// you can pass group name for given files as second parameter\n// default group name is \"default\"\n$this-\u003eminify-\u003ejs(array('html5.js', 'main.js'), 'extra');\n$this-\u003eminify-\u003eadd_css('style.css, tinybox.css', 'another');\n\n// deploy css\n// bool argument for rebuild css - false means skip rebuilding (default value: TRUE) \necho $this-\u003eminify-\u003edeploy_css(TRUE);\n\n//Output: '\u003clink href=\"path-to-compiled-css\" rel=\"stylesheet\" type=\"text/css\" /\u003e'\n\n// deploy js\n// bool argument for rebuild js  - false means skip rebuilding (default value: FALSE)\necho $this-\u003eminify-\u003edeploy_js(); \n\n//Output: '\u003cscript type=\"text/javascript\" src=\"path-to-compiled-js\"\u003e\u003c/script\u003e'.\n\n// you can use automatic file name for particular deploy when you have $config['auto_names'] set to FALSE\n// to do so, you must set file name to 'auto' during deploy\necho $this-\u003eminify-\u003edeploy_css(TRUE, 'auto');\necho $this-\u003eminify-\u003edeploy_js(TRUE, 'auto');\n\n//Output: '\u003clink href=\"path-to-compiled-css-with-auto-file-name\" rel=\"stylesheet\" type=\"text/css\" /\u003e'\n//Output: '\u003cscript type=\"text/javascript\" src=\"path-to-compiled-js-with-auto-file-name\"\u003e\u003c/script\u003e'.\n\n// you can deploy only particular group of files\necho $this-\u003eminify-\u003edeploy_css(TRUE, NULL, 'another');\necho $this-\u003eminify-\u003edeploy_js(TRUE, 'auto', 'extra'); \n\n//Output: '\u003clink href=\"path-to-compiled-css-group\" rel=\"stylesheet\" type=\"text/css\" /\u003e'\n//Output: '\u003cscript type=\"text/javascript\" src=\"path-to-compiled-js-group-with-auto-file-name\"\u003e\u003c/script\u003e'.\n\n// you can enable versioning your your assets via config variable `$config['versioning']` or manually\n$this-\u003eminify-\u003eversioning = TRUE;\necho $this-\u003eminify-\u003edeploy_js(); \n\n//Output: '\u003cscript type=\"text/javascript\" src=\"path-to-compiled.js?v=hash-here\"\u003e\u003c/script\u003e'.\n```\n    \n## Changelog\n\n01 Mar 2021\n* comments fixing\n* config checks only when deploy\n\n26 Jul 2019\n* added option to manually change version number for assets (thanks [screamingjungle](https://github.com/screamingjungle))\n\n11 Feb 2019\n* fixed an issue where not all config variables from the constructor were taken into account\n\n02 Feb 2019\n* new config variable to allow of use a custom domain/subdomain for your assets: `$config['base_url']` (default to '')\n\n25 Jul 2018\n* new config variable to disable default behavior - deploy when any file is changed: `$config['change_on_deploy']` (default to TRUE)\n\n24 Jul 2018\n* handle errors for closurecompiler engine\n\n26 Feb 2018\n* new config variable to determine if we want to return html tags (as string result) or only links to the assets (as array): `$config['html_tags']` (default to TRUE)\n* we can now specify what HTML tag will be used for CSS and JS through `$config['css_tag']` and `$config['js_tag']`\n\n17 Jun 2017\n* new config variable to enable versioning assets `$config['versioning']` (default to FALSE)\n* new config variable to enable/disable library - useful for debugging: `$config['enabled']` (default to TRUE)\n\n29 Dec 2016\n* introduce option to save compiled css and js files in different folders - new config variables: `$config['assets_dir_css']` and `$config['assets_dir_js']`.\n\n29 Apr 2015\n* allow using automatic file name for particular deploy when you have `$config['auto_names']` set to `FALSE`\n* documentation update\n\n20 Apr 2015\n* Closure compiler configuration extracted to config file \n\n22 Mar 2015\n* method chaining support\n* new methods: `add_css()` and `add_js()` - gives ability for adding files to existing files arrays\n* added support to run library with custom array config, assigned as second parameter (during loading) `$this-\u003eload-\u003elibrary('minify', $config);`\n* added support for *groups* in files arrays - as second (optional) parameter in methods: `css()`, `js()`, `add_css()` and `add_js()` (i.e. `$this-\u003eminify-\u003ejs(array('script.js'), 'extra');` - default group name is *default*)\n* added support for strings as first parameter in methods: `css()`, `js()`, `add_css()` and `add_js()` (i.e. `$this-\u003eminify-\u003ejs('first.js, second.js');`)\n* added support for automatic files names: `$config['auto_names'] = TRUE;`\n* external compression classes moved to *minify* folder\n* unit tests for new features\n\n10 Feb 2015\n* Unit testing\n\n09 Feb 2015\n* 2 new engines to compress JS files\n* documentation update\n\n13 Oct 2014\n* changed way of generating JS file\n\n14 July 2014\n* small bug fixes in JS compression\n\n4 July 2014\n* sample JavaScript files to see how it works \n* detection of empty JS file causes force refresh\n\n23 May 2014\n\n* you can chose your compression engine library in config file (CSS only)\n* speed optimisations\n* force CSS rewrite using $this-\u003eminify-\u003edeploy_css(TRUE);\n\n11 Mar 2014\n\n* completely rewrite CSS parser - uses cssmin compress CSS,\n* detects file modification time no longer force rewrites,\n* example usage now included withing app\n\n## Any questions?\n\nReport theme here: \u003chttps://github.com/slav123/CodeIgniter-minify/issues\u003e\n","funding_links":[],"categories":["Libraries","Asset Management"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslav123%2FCodeIgniter-minify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslav123%2FCodeIgniter-minify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslav123%2FCodeIgniter-minify/lists"}