Giter Club home page Giter Club logo

codeigniter-minify's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-minify's Issues

Comments on last line trigger a bug

If a JS file has a //comment on the last line (without any newline after), the concatenated code is wrong, causing errors of the js compiler.
I'm submitting a pull request to fix this bug by appending a newline after the contents of each file.
Hopefully there is a better solution.

Generated filename is concatenating group names

Hi! Just a minor annoying issue... but if one creates, for example, three groups of css and/or js files named "head", "body" and "foot" by issuing:

$this->minify->js(["one.js", "two.js"], "head");
$this->minify->js(["three.css", "four.js"], "body");
$this->minify->js(["five.js"], "foot");

and deploy every one via:

echo $this->minify->deploy_js(ENVIRONMENT !== 'production', NULL, 'head');
echo $this->minify->deploy_js(ENVIRONMENT !== 'production', NULL, 'body');
echo $this->minify->deploy_js(ENVIRONMENT !== 'production', NULL, 'foot');

Than the generated names will be concatenated like this:

head_scripts.min.js
body_head_scripts.min.js
foot_body_head_scripts.min.js

I don't know if that is the author intention, but I think the final names should be:

head_scripts.min.js
body_scripts.min.js
foot_scripts.min.js

Regards.

Closurecompiler cache option

In my development area i've tested the output on all files i need to combine and minify, but on multiple files it seems to slow down to about 3 sec.

Does this library offer some sort of cache option to only allow recombine after a period of time so the speed stays optimized or do i need to just download the file and inlcude it manualy?

Need to look in more than one file

hi
Is it possible to look for js or css files in more than one location how to specify in minify.php config
(where to look for js files (default value: 'assets/js'))

Browser cache does not work with the library

Hi all,
I tried to use the library and I was able to generate minified files for CSS and JS, but then I realized that the browser is not caching them and every time it was fetching these files from the server.
Is there any way we can use the browser cache functionality along with this library.
Thanks.

change default ClosureCompiler to jsmin

Need to change ClosureCompiler as the default to jsmin or just remove ClosureCompiler.js as it isn't supported? Unless the main author gave the project to some one else it appears to be archived.

Using Multiple Directories

Hi there,first of all thanks for this awesome library.
Can we select multiple directories?
ie. Separated files for back-end and front-end?

$config['js_file'] not working properly

I'm using this code
$this->load->library('minify'); $minify_config['js_file'] = 'newtable.js'; $minify = new Minify($minify_config); $minify->js(array('tables.js'));

I want my own name of js_file, but they return me alway the same js name file: script.min.js
I'm using PHP7.2

not found library class

Unable to load the requested class "minify" . . . i'm use load->library


//my minify library path is application/libraries/Minify
$this->load->library('minify');

no scan

How about no scan files in dir or no check file mod.

Increase in server response time

I have used a couple of js and css under compression on local server and tested it at Google Page Speed tool.

Now there is a server response delay of 4 sec. Any chance, I can reduce it to the min?

My code:
$this->minify->add_js(['1.js','2.js','3.js','4.js','5.js','6.js','7.js'], 'essentials_javascript');
$this->minify->deploy_js();

I wonder if that's possible!

"compression_engine" works like a charm! Can we obfuscate div ids or classes name as well and put it back to html page. For e.g.
--------------------Input--------------------------

This is an idea

..... css file ....
#hi{
color:black;
}
.test{
font-size:1rem;
}

-------------------Output--------------------------

This is an idea

..... css file ....
#0typs_123{ color:black;}.lpsd{font-size:1rem;}

How to cache?

Hello,
is there a way to cache the output files? or it's already cached by this library?

Minify converting domain to ip

I am adding this code to footer

if ( isset( $this->minify ) ) {
	$this->minify->add_js( [ 'profile.questions.load_more.js', 'question.comments.load_more.js' ] );
	echo $this->minify->deploy_js( true, 'auto' );
}

it is working fine on localhost but when I am deploying to production, it is converting domain to IP.
I want: http://localhost/assets/1c4a7deccc90cfe0629ecaba41da0dbe.min.js
Minify converting to http://127.0.0.1/assets/1c4a7deccc90cfe0629ecaba41da0dbe.min.js

Using along with CodeIgniter.
Minify version : latest

how can i make a group of two compressed js for four different js files?

In total, i have 4 js files and i would like to make 2 different groups of 2 js each with compression. The current deploy_js adds the rest of two in previous compressed two.

 $this->minify->add_js('pace.min.js')->add_js('animsition.min.js');
 echo $this->minify->deploy_js();
 $this->minify->add_js('scrollreveal.min.js')->add_js('footer.js');
 echo $this->minify->deploy_js();

Any thought?

Difficult to run every time

Hi
My problem is that in my project, every time the page loads, the library runs and re-compresses the files.
This will cause heavy loading.
How to set it to run once every 3 days, for example.
Or just run again in case of changes?

Assets from CDNs

I liked your library, but it lacks support to retrieving content from external sites like CDNs. The idea is to add a function to store the content of an assets with cURL and write it compressed to the unified css/js file.

Some casuistries not covered on JS

1

data: {
  customer_email: customer_email,
  customer_firstname: customer_firstname,
}

Last colon is an error, but jQuery skip that with no issue.
The minifier returns an empty script when it founds that.

2

When the minifier detects on the array of files a file modified after the last time, it generates the resulting script, it generates a new one. It rocks. But...
When you add to the array of files a new file wich its last modified date is previous to the resulting script modified date, it does not generates a new one.

JS minify not working

$menu = 'mmenu.min.js';
$tippy = 'tippy.all.min.js';
$simplebar = 'simplebar.min.js';
$bootstrap_slider = 'bootstrap-slider.min.js';
$simplebar_select = 'bootstrap-select.min.js';
$snackbar = 'snackbar.js';
$clipboard = 'clipboard.min.js';
$counterup = 'counterup.min.js';
$magnific = 'magnific-popup.min.js';
$slick = 'slick.min.js';
$custom = 'custom.js';
$all_js = array($menu,$tippy,$simplebar,$bootstrap_slider,$simplebar_select,$snackbar,$clipboard,$counterup,$magnific,$slick,$custom);
$this->minify->js($all_js);
echo $this->minify->deploy_js();

Strip cache busting from filenames

Inside _scan_files() you can filter out any cachebusting on the files.

for example, some would use /style.css?version=1
this creates an error so you'll want to discard anything after ?

something like:
$filename = $directory . '/' . preg_replace('#\?.*#', '', $file);

You find this again inside _concat_files()
$file_name = $directory . '/' . preg_replace('#\?.*#', '', $file_name);

You should strip all the filenames entered into Minify.

Question regarding compiled javascript source path (double slash)

Nothing serious, but I get a double slash after the base url, like http://www.example.com//assets/script.min.js.

Am I doing something wrong? Configuration is like explained in the example:

$config['assets_dir'] = 'assets';
$config['css_dir'] = 'assets/css';
$config['js_dir'] = 'assets/js';

I guess the second slash is from Minify#deploy_js:384

return "<script type=\"text/javascript\" src=\"" . base_url() . '/' . $this->js_file . "\"></script>";

CI config.php states the base URL comes with a trailing slash, so the one separator after base_url() is the second one.

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/

Add clearstatcache();

When I develop an application, I often reload the script data, but the "filesize" function in "linux" has a cache. Subsequently, files are not generated until the end.

Add before

clearstatcache();
$contents = fread($handle, filesize($out_file));

Add versioning to simple output when disabled

Sometimes one wants to switch off the minification but keep the cache busting/versioning on the output.

in _simple_output()

		foreach ($files as $file)
		{
			$filename = $directory . '/' . $file;

			if ($this->versioning)
			{
				$filename .= '?v=' . md5_file($filename);
			}

			$output[] = $filename;
		}

A PHP Error was encountered

I'm testing your library with your example css and js files and when it generate the minified files I get this errors but the files are correctly generated.

I'm working with codeigniter 2.2.0.

A PHP Error was encountered

Severity: Notice

Message: Undefined index: css

Filename: libraries/Minify.php

Line Number: 224

A PHP Error was encountered

Severity: Notice

Message: Undefined index: css

Filename: libraries/Minify.php

Line Number: 224

A PHP Error was encountered

Severity: Notice

Message: Undefined index: js

Filename: libraries/Minify.php

Line Number: 224

A PHP Error was encountered

Severity: Notice

Message: Undefined index: js

Filename: libraries/Minify.php

Line Number: 224

Minify CI4

Hi,

First of all, I really appreciate the effort you put in this GIT project to help us all make CI faster.
Currently i'm working with CI4 to see if my application is compatible, but in CI3 i'm using your minifier.

Do you have plans on creating this for CI4 also?

Kind regards,

Any tips on this error?

A PHP Error was encountered

Severity: Warning

Message: touch(): Unable to create file assets/styles.min.css because No such file or directory

Filename: libraries/Minify.php

Line Number: 450

The each() function is deprecated. This message will be suppressed on further calls

Hi,
First of all thanks for your contribution, this library is really awesome. However, I am facing a very tiny issue which I hope you can rectify in sometime. I changed the css minify library to "cssmin" but, I got the following error.

Thank you!

**A PHP Error was encountered
Severity: 8192

Message: The each() function is deprecated. This message will be suppressed on further calls

Filename: Minify/cssmin-v3.0.1.php

Line Number: 2222

Backtrace:

File: C:\xampp\htdocs\sites\lakhina-couture\application\libraries\Minify\cssmin-v3.0.1.php
Line: 2222
Function: each

File: C:\xampp\htdocs\sites\lakhina-couture\application\libraries\Minify\cssmin-v3.0.1.php
Line: 2315
Function: initialise

File: C:\xampp\htdocs\sites\lakhina-couture\application\libraries\Minify.php
Line: 715
Function: require_once

File: C:\xampp\htdocs\sites\lakhina-couture\application\libraries\Minify.php
Line: 650
Function: _cssmin

File: C:\xampp\htdocs\sites\lakhina-couture\application\libraries\Minify.php
Line: 537
Function: _concat_files

File: C:\xampp\htdocs\sites\lakhina-couture\application\libraries\Minify.php
Line: 394
Function: _scan_files

File: C:\xampp\htdocs\sites\lakhina-couture\application\libraries\Minify.php
Line: 330
Function: _deploy_css

File: C:\xampp\htdocs\sites\lakhina-couture\application\controllers\Deploy.php
Line: 20
Function: deploy_css

File: C:\xampp\htdocs\sites\lakhina-couture\application\controllers\Deploy.php
Line: 12
Function: _minify_backend

File: C:\xampp\htdocs\sites\lakhina-couture\index.php
Line: 273
Function: require_once**

Using $config['base_url'] in config.php causes malformed URLs.

Using $config['base_url'] in the default config.php will cause malformed generated URLs.

Example:

$config['base_url'] = 'https://example.com/'; 

Results:

<script type="text/javascript" src="https://example.com/https://example.com/assets/scripts.min.js"></script>

Closure Compiler Service API via https now

Please change it
private function _closurecompiler($data) {
on
private function _closurecompiler($data) { $config = $this->closurecompiler; $ch = curl_init('https://closure-compiler.appspot.com/compile'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=' . $config['compilation_level'] . '&js_code=' . urlencode($data)); $output = curl_exec($ch); curl_close($ch); return $output; }

Option to disable minfy and combine

In development environment every developer need to debug the bugs. If a boolen value provided in config when we need we can disable it . I suggest this as improvement

Versionning

Hello

Is that possible to include a parameter to add a ?version= for a CSS/JS minified file if build is set to TRUE (or if build has been made because of a change in the files) ?

I got a cache system for JS/CSS files and I need to clear cache to update and get last version of file
With ?version= I won't need anymore to clear cache as it will add a new version each time it builds

Regards

minified folder must be the same as assets folders

Hi,

How to generate minified folder in the same folder as the css and js files ?

If my css file is in assets/css and js in assets/js I would like minified versions created in the same folder.
In the config file, it is only possible to set an unique asset folder for generated files. So we can't specify different folders for css and js.

Relative URL to images in css files will be broken if minified file is not generated in the same folder!

Licensing

Hello,
could you please specify a license for CI-minify?
Otherwise I won't be able to use it.
Thanks,
Domenico

Not working for me

I did as told in the read me, it's not deploying. I checked the file permission, but in vain.

More Directories

Hello
how i can set my another files Directories
for example:
Assets/css/bootstrap/bootstrap.min.css
Assets/css/font-awesome/font-awesome.min.css

thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.