Jump to content

Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML


David Karich

Recommended Posts

you'd need to make some function to output the individual assets, for example when an admin is logged in..

(very basic example)
 

if($user->isLoggedin) {
  listAssets($stylesheets);
} else {
  echo AllInOneMinify::CSS($stylesheets));
}

that's how i do it..

  • Like 4
Link to comment
Share on other sites

Uh now I understand the question..development mode is just disabling minification and caching..maybe file "seperation" could be included as separate option, I for myself like files being concatenated while uncompressed for development..and if I really don't now which file a line belongs to I just Sublime search in all files and done.. ;-)

Link to comment
Share on other sites

5 hours ago, Macrura said:

 


if($user->isLoggedin) {
  listAssets($stylesheets);
} else {
  echo AllInOneMinify::CSS($stylesheets));
}

 

My conditional is:

$skipMinify = $config->debug || $user->isSuperuser() ? true : false;

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, tpr said:

@horst How about this?

$skipMinify = $config->debug || $user->isSuperuser();

Where does this code snippet go?

Right now I am using this code in my header which is not very professional but it works ;-)

	<? if ($config->debug) { ?>
		<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/styles.css" />
	<? }
	else { ?>
		<link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS('styles/styles.css'); ?>" />
	<? } ?>

 

Link to comment
Share on other sites

For me, it goes here:

// condition
<?php if ($config->debug) { ?>

// condition as variable
<?php
$skipMinify = $config->debug || $user->isSuperuser();
if ($skipMinify) { ?>

// or, if you have only one occurence in your code where you check this condition, 
// ommit the temorary variable and write it direct into the condition
<?php if ($config->debug || $user->isSuperuser()) { ?>

$config->debug is true when developing, and additionally I use superuser condition for later, when in production mode!

  • Like 2
Link to comment
Share on other sites

  • 2 months later...

PHP 7.1 is returning a:

A non well formed numeric value encountered on line 713 notice

because you are relying on PHP's auto int casting.

I didn't do a thorough check to see if this is ok, but so far it's working for me:

$_timestamp = ((int)$_timestamp + $file['last_modified']);

 

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 2 months later...

Hi,

first I couldn't install the module on a 3.0.47 installation, I've added  namespace ProcessWire;, which did the trick, but then I have this:

Error: Class 'ProcessWire\RecursiveDirectoryIterator' not found (line 658 of /public_html/site/modules/AllInOneMinify/AllInOneMinify.module)

Kind Regards!

Link to comment
Share on other sites

On 18.11.2016 at 4:48 PM, Zeka said:

Hi.

Is it possible to disable HTML minifing or activate "Developement mode" from config file? 

Thanks 

Not directly, but I had the same "problem" and now I do it this way:

// when debug mode is ON -> do not compress the styles 
if ($config->debug) { ?>
	<link rel="stylesheet" type="text/css" href="/path/to/css/..."/>
<? } else { ?>
	<link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS(/path/to/css/...); ?>"/>
<? }

 

  • Like 1
Link to comment
Share on other sites

13 hours ago, videokid said:

Hi,

first I couldn't install the module on a 3.0.47 installation, I've added  namespace ProcessWire;, which did the trick, but then I have this:


Error: Class 'ProcessWire\RecursiveDirectoryIterator' not found (line 658 of /public_html/site/modules/AllInOneMinify/AllInOneMinify.module)

Kind Regards!

you either leave the namespace or need to prepend all php function like RecursiveDirectoryIterator with an \ backslash like \RecursiveDirectoryIterator so it knows this function is not in the ProcessWire but in the root namespace..

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...
On 19.01.2017 at 11:06 AM, Stefanowitsch said:

Not directly, but I had the same "problem" and now I do it this way:


// when debug mode is ON -> do not compress the styles 
if ($config->debug) { ?>
	<link rel="stylesheet" type="text/css" href="/path/to/css/..."/>
<? } else { ?>
	<link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS(/path/to/css/...); ?>"/>
<? }

 

 
 

@Stefanowitsch Thanks for tip, but it isn't relative to HTML minifying.

Link to comment
Share on other sites

  • 2 months later...

I just found a collision cache file naming issue if all files have the same modified timestamp regardless of the array contents.

Simple fix to ensure the filename itself is included in the MD5($_timestamp)

$_timestamp = ($_timestamp + $file['last_modified'] . basename($file['absolute_path']));

https://github.com/FlipZoomMedia/ProcessWire-AIOM-All-In-One-Minify/issues/64

Link to comment
Share on other sites

  • 2 weeks later...

Wanted to let you know, that I had some issues with AOIM running php 7.

Error messages were generated because of non well formed numeric values.
Maybe the issues are bound to my hosting environment. The following changes resolved them

Changend line 775 in /site/modules/AllInOneMinify/lib/cssmin.php to:

return intval($size);

Changed line 713 in site/modules/AllInOneMinify/AllInOneMinify.module to

$_timestamp = intval($_timestamp . $file['last_modified']);

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Hi all,

I'm using the AIOM+ module for speeding up my page. My website is using SSL.

In the module there's the option for domain sharding. Without SSL it's working perfectly, but as soon as I access the website via SSL it's not working. Seems like the Option "Domain sharding (SSL)" is beeing totally ignored.

Is there anybody with the same problem?

Thanks!
Dennis

Link to comment
Share on other sites

Just wanted to add another report of non-well formed numeric values occurring with PHP 7 (specifically 7.1.7). Pmichaelis' solution works, but only allowed the caching of a single CSS and JS file for my entire site, while Adrian's (several posts above) works and allows for several of each. That said, AIOM still breaks when a template calls for a file that hasn't been previously generated with either of those solutions and remains so even on a reload when a cached file should be available. To get that original page working, I need to jump to a different page using that template (which renders correctly) and then back to the original page.

Edit: ...and by break, I mean it adds a string error message (with some HTML) to the SRC path for each item in your array, so the browser tries to load the CSS or JS file at a URL consisting of multiple error messages followed by the correct path in one epically long string.

  • Like 1
Link to comment
Share on other sites

On 21. 5. 2017 at 1:21 PM, theo said:

Just a detail: Why are these br tags visible in the module config?

Sth. changed in Processwire?

aiombr.png

    

...
$field->entityEncodeText = false; //add this to allow html markup
$field->description.= sprintf(__('Cached files: %s | Used space: %s'), $_cacheInfo['numberOfFiles'], $_cacheInfo['bytesTotal']);
...

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi!

I would like to use "HTML minify" but leave some of the html comments in the code.

In my case it is this comment:

<!-- HTML5 elements and media queries Support for IE8 : HTML5 shim and Respond.js -->
		<!--[if lt IE 9]>
			<script src="js/html5shiv.js"></script>
			<script src="js/respond.min.js"></script>
		<![endif]-->

Is there a way to exclude some comments from being deleted by the module?

Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...