David Karich

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

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

Share this post


Link to post
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.. ;-)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@horst How about this?

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

  • Like 5

Share this post


Link to post
Share on other sites

:o OMG. I shouldn't post in the morning before the first cup of coffee. :)

 

  • Like 4

Share this post


Link to post
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'); ?>" />
	<? } ?>

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
On 11/25/2015 at 5:17 PM, Russ Parker said:

Any ideas how to stop it minifying the spaces in CSS calc?

having a problem with this as well, any solutions ?

Share this post


Link to post
Share on other sites

Hi.

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

Thanks 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Yes,

I left the ' namespace Processwire ' and added the backslash, and that did the trick!

Thank you!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Sth. changed in Processwire?

aiombr.png

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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']);
...

 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By BitPoet
      So I stumbled over the request to allow limiting templates to be used only once under every parent page in this thread
      and found that this would actually come in handy (also in a site I've built).
      The code can be found on github and soon in the module repo.
      After installation, you'll find a new checkbox "Only once per parent" in the family tab when editing a template.

    • By Robin S
      Password Generator
      Adds a password generator to InputfieldPassword.

       
      Usage
      Install the Password Generator module.
      Now any InputfieldPassword has a password generation feature. The settings for the generator are taken automatically from the settings* of the password field.
      *Settings not supported by the generator:
      Complexify: but generated passwords should still satisfy complexify settings in the recommended range. Banned words: but the generated passwords are random strings so actual words are unlikely to occur.  
      https://modules.processwire.com/modules/password-generator/
      https://github.com/Toutouwai/PasswordGenerator
    • By Robin S
      If you've ever needed to insert links to a large number of files within CKEditor you may have found that the standard PW link modal is a somewhat slow way to do it.
      This module provides a quicker way to insert links to files on the page being edited. You can insert a link to an individual file, or insert an unordered list of links to all files on the page with a single click.
      CKEditor Link Files
      Adds a menu to CKEditor to allow the quick insertion of links to files on the page being edited.

      Features
      Hover a menu item to see the "Description" of the corresponding file (if present). Click a menu item to insert a link to the corresponding file at the current cursor position. The filename is used as the link text. If you Alt-click a menu item the file description is used as the link text (with fallback to filename if no description entered). If text is currently selected in the editor then the selected text is used as the link text. Click "* Insert links to all files *" to insert an unordered list of links to all files on the page. Also works with the Alt-click option. Menu is built via AJAX so newly uploaded files are included in the menu without the page needing to be saved. However, descriptions are not available for newly uploaded files until the page is saved. Installation
      Install the CKEditor Link Files module.
      For any CKEditor field where you want the "Insert link to file" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "LinkFilesMenu" to the "CKEditor Toolbar" settings field.
       
      http://modules.processwire.com/modules/cke-link-files/
      https://github.com/Toutouwai/CkeLinkFiles
    • By matjazp
      A module for managing files and folders. Supports creating, opening (e.g. viewing, playing, editing), renaming, moving, copying, deleting and searching for files. You can also view and change (not supported on Windows) file and directory permissions. 
      https://github.com/matjazpotocnik/ProcessFileManager

      The author of FileManager component is (c) 2006 - 2018 Gerd Tentler, http://www.gerd-tentler.de/tools/filemanager/. I modified it to work with ProcessWire as a module. Please see license files on usage in commercial projects!
    • By Robin S
      An inputfield for displaying markup editable via CKEditor.
      The module is intended for use with the Form Builder module. Allows blocks of static text to be included within a form, which can be edited in the form settings using CKEditor.
      Usage
      Install the Markup CKEditor module.
      In the Form Builder module settings, add "MarkupCKEditor" to "Inputfield types to use with FormBuilder".
      In your form settings, add a new field of type "Markup CKEditor". Enter the text you want to show in this field using "Markup Text" on the "Details" tab.
      Screenshots


       
      http://modules.processwire.com/modules/inputfield-markup-ckeditor/
      https://github.com/Toutouwai/InputfieldMarkupCKEditor