Jump to content

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


David Karich

Recommended Posts

i don't know what the code does exactly, so if you also don't understand it in detail you have 3 options

  • wait and hope that somebody else helps you
  • you invest some time, learn something about REGEX and try to find a way that prevents the module of minifying your comments
  • buy procache for 49$ and be happy (for 1 site) and benefit of a lot more options and improvements that it offers (or pay 169$ for unlimited sites)

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Hi,

I switched my site to https and now I can't get AIOM to running. Here are the errors I'm getting:

Mixed Content: The page at 'https://****/' was loaded over HTTPS, but requested an insecure stylesheet 'warning: A non-numeric value encountered in /mnt/****/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module on line 713/work/roltek/site/assets/aiom/css_b863322778056fb524ea6127cc06763c_dev.css?no-cache=1503581072'. This request has been blocked; the content must be served over HTTPS.
(index):1 Mixed Content: The page at 'https://****/' was loaded over HTTPS, but requested an insecure script 'warning: A non-numeric value encountered in /mnt/****/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module on line 713/work/roltek/site/assets/aiom/js_656d424f993dafdaf7bd972288171ab2_dev.js?no-cache=1503581072'. This request has been blocked; the content must be served over HTTPS.

When I disable AIOM everything works like it should be. Any ideas?

EDIT: 

In order to debug this error I generated a subdomain without HTTPS encription. Now I get the following error:

Warning: A non-numeric value encountered in /***/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module on line 713
/site/assets/aiom/js_656d424f993dafdaf7bd972288171ab2_dev.js?no-cache=1503583266

EDIT: 

I've figured out, that the error only happens, when I'm using PHP Ver. 7.1. with PHP Ver. 7.0. everything works like it should be. 

 

Many greets, Jens alias DV-JF

Link to comment
Share on other sites

  • 4 weeks later...

Hi

I tried to add AIOM to my website but I can't figure why I have this error message :

Class 'ProcessWire\AIOM' not found

<script src="<?php echo AIOM::JS(array('scripts/jquery.unveil.js', 'scripts/jquery-popup.js')); ?>"></script> 

What I did wrong?

Thanks

Mel

PW3.0.75 AIOM 3.2.3

Link to comment
Share on other sites

just a stab at this - it may depend on how the file with that code is being included; you can try a backslash in front of the AIOM and see if that works, or you can instantiate the AIOM into a variable like $aiom = $modules->get('AllInOneMinify') or whatever the class name of the module is..

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hello everyone,

I'm new in Processwire CMS.

and when i create my first website on it i notice it's very slowly.

i tried use AIOM module to resolve the problem but when i try using this 

Quote

<script src="<?php echo AIOM::JS(array('js/jquery-2.1.0.min.js', 'js/jquery-ui.min.js', 'js/jquery.queryloader2.min.js')); ?>"></script>

the website doesn't open it's appear Blank page

can anybody help me, and tell me where the problem?

Thanks.

Link to comment
Share on other sites

It seems like you don't really need the AIOM module anymore - all the 3 JS files are already minified. The only advantage you'd have is the concatenation (1 instead of 3 files).

What do you see when you open the browser inspector?

As for the general slowness of the site - we would need more hints/infos.

Link to comment
Share on other sites

@Ahmad

 This module has a problem in the AllInOneMinify.module file ... When you go to the processwire installation directory and

site\modules\AllInOneMinify/AllInOneMinify.module

And change this code from the line 713:

foreach ($files as $file) {
$_timestamp = ($_timestamp + $file['last_modified']);
}

Change to :

foreach ($files as $file) {
$_timestamp = ($file['last_modified']);
}

I only deleted the variable " $_timestamp + " and it worked ... But I do not know if it will have any later consequences ...

In addition, you should install a great debugging module that will help you find problems with the name Tracy Debugger

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, dragan said:

It seems like you don't really need the AIOM module anymore - all the 3 JS files are already minified. The only advantage you'd have is the concatenation (1 instead of 3 files).

What do you see when you open the browser inspector?

As for the general slowness of the site - we would need more hints/infos.

these js only example

Link to comment
Share on other sites

2 hours ago, rafaoski said:

@Ahmad

 This module has a problem in the AllInOneMinify.module file ... When you go to the processwire installation directory and

site\modules\AllInOneMinify/AllInOneMinify.module

And change this code from the line 713:


foreach ($files as $file) {
$_timestamp = ($_timestamp + $file['last_modified']);
}

Change to :


foreach ($files as $file) {
$_timestamp = ($file['last_modified']);
}

I only deleted the variable " $_timestamp + " and it worked ... But I do not know if it will have any later consequences ...

In addition, you should install a great debugging module that will help you find problems with the name Tracy Debugger

Thank u, It's worked method with JS.

and still the problem with css files.

  • Like 1
Link to comment
Share on other sites

@Ahmad ... My styles and scripts look like this ( Remember the slash before \AIOM ):

<link rel="stylesheet" href="<?php echo \AIOM::CSS(array('assets/css/uikit.min.css', 'styles/main.css')); ?>">
<script src="<?php echo \AIOM::JS(array('assets/js/uikit.min.js', 'assets/js/uikit-icons.min.js')); ?>"></script>

I using Processwire Version 3.0.81 DEV with Uikit 3 site/blog profile ...

Sometimes also a test environment can cause problems (the last one I had trouble because I used xampp server) which I swapped by going to Laragon development environment for Windows ...

More options you have in the module, where I usually clean the system cahe ( Empty Cache ) in Menu => Modules/Site/AllInOneminify:

screen-2.thumb.png.5444a64e30e682074823b4f869c76c83.png

screen-1.thumb.png.3436f68e108604e5ed6082b00589b1c1.png

You can remove cache folders from site\assets\cache  and also remove browsing history in chrome or firefox to clear browsing data and finally refresh page and see if it works ...

 

Link to comment
Share on other sites

Maybe this can help?

 //https://github.com/FlipZoomMedia/ProcessWire-AIOM-All-In-One-Minify/issues/64
 $_timestamp = ((int)$_timestamp + $file['last_modified'] + hexdec(md5(basename($file['absolute_path']))));

 

  • Like 2
Link to comment
Share on other sites

Hello Community, 
just used AIOM for the first time and ran in some of the issues mentioned above. Got it to work with the help of this thread. Thank you guys. 

Just in case someone finds it useful I add additionally some steps to update the CssMin Library quickly, until we get the next AIOM Update:

  • Create Folder site/modules/AllInOneMinify/lib/CssMin
  • Get the four files from: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/tree/master/src (Colors.php, Command.php, Minifier.php, Utils.php) and put them in the folder above.
  • Remove namespacing after php tag in these files (i.e. delete namespace tubalmartin\CssMin;)
  • Change code in site/modules/AllInOneMinify/AllInOneMinify.module:
  • Z.541 replace the require_once statement where it includes the CssMin Class File with:
// require_once(wire('config')->paths->AllInOneMinify.'lib/CssMin'.DIRECTORY_SEPARATOR.'cssmin.php');
require_once(wire('config')->paths->AllInOneMinify.'lib/CssMin'.DIRECTORY_SEPARATOR.'Minifier.php');
require_once(wire('config')->paths->AllInOneMinify.'lib/CssMin'.DIRECTORY_SEPARATOR.'Colors.php');
require_once(wire('config')->paths->AllInOneMinify.'lib/CssMin'.DIRECTORY_SEPARATOR.'Command.php');
require_once(wire('config')->paths->AllInOneMinify.'lib/CssMin'.DIRECTORY_SEPARATOR.'Utils.php');
  • Z.620 replace the following line
// $cssMin = new CSSmin();
$cssMin = new Minifier();

That did the job for me.

Link to comment
Share on other sites

4 hours ago, matjazp said:

I have a forked version at https://github.com/matjazpotocnik/ProcessWire-AIOM-All-In-One-Minify that includes a lot of pull requests and fixes from several contributors. Test on dev site first!!!

 

Seems to me that you should take over this project and the modules directory should point to your fork.

Is it time to PM @David Karich and get the ball rolling :)

  • Like 1
Link to comment
Share on other sites

To be honest I don't have enough knowledge on what's really going on in the source files, I just included fixes and PR's from others, hoping that it might help them. But it's not a problem for me to maintain this fork with PR's of other contributors, if that helps.

Link to comment
Share on other sites

This new fork doesn't work at all for me. Well, it did work, but as soon as I needed to clear the cache (after adding/changing some CSS/JS), I get a fatal error.

Exception: DirectoryIterator::__construct(C:/xampp/htdocs/xxx/site/assets/cache/Page/,C:/xampp/htdocs/xxx/site/assets/cache/Page/): 
Das System kann die angegebene Datei nicht finden. (code: 2) 
(in C:\xampp\htdocs\xxx\wire\core\CacheFile.php line 240)

Das System kann die angegebene Datei nicht finden = the system can't find the supplied file

Also, the HTML doesn't get minified at all, although it's checked in the module settings.

PW 3.0.82, Tracy Debugger active, debug-mode true, local install

Link to comment
Share on other sites

Please provide the full stack (everything in red). It looks like C:/xampp/htdocs/xxx/site/assets/cache/Page/ folder is not found/accessible? Does it help if you run aiom in development mode? 

After providing above answers, please replace /site/modules/AllInOneMinify/AllInOneMinify.module with this one attached.

AllInOneMinify.module

Link to comment
Share on other sites

  • 2 weeks later...

For me, this works:
 

    private static function _getCacheName($files, $prefix = 'css_', $ext = '.css') {
        
        // ------------------------------------------------------------------------
        // Initialize timestamp variable.
        // ------------------------------------------------------------------------
        $_timestamp = 0; //<-theo

        // ------------------------------------------------------------------------
        // Calculate timestamp of all files
        // ------------------------------------------------------------------------
        foreach ($files as $file) {
            //$_timestamp = ($_timestamp + $file['last_modified']);
            $_timestamp += ($file['last_modified'] + hexdec(md5(basename($file['absolute_path'])))); //<--theo
        }
        // ------------------------------------------------------------------------
        // Create a unique MD5 file name with the specified prefix.
        // ------------------------------------------------------------------------
        return (self::$developmentMode !== true) ? $prefix.md5($_timestamp).$ext : $prefix.md5($_timestamp).'_dev'.$ext;
    }

..when using AIOM like this:
 

        <?php
        $stylesheets = array(
            array('loadOn' => 'template=home', 'files' => array('styles/kuengmain.css')),
            array('loadOn' => 'template=categories', 'files' => array('styles/jquery.fullpage.css','styles/kuengmain.css')),
            array('loadOn' => 'template=kontakt', 'files' => array('styles/bootstrap_ms.css','styles/kuengmain.css')),
            );
        ?>

        <link rel="stylesheet" type="text/css" href="<?php echo AllInOneMinify::CSS($stylesheets); ?>" />

 

Because different files may have the same timestamp.

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...