Jump to content
David Karich

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

Recommended Posts

Hi Bernhard,

thank you for your answer.

Maybe there is another way to solve this with this modul?

Thanks!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Enable debug mode in site/config.php. You're probably getting an error that's preventing PW to complete page render.

  • Like 1

Share this post


Link to post
Share on other sites

Hello @Ahmad ... You must add a backslash before \AIOM like:

<script src="<?php echo \AIOM::JS(array('assets/js/uikit.min.js', 'assets/js/uikit-icons.min.js')); ?>"></script>

In this case, the js files are in the assets / js directory ...

  • Like 1

Share this post


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

Share this post


Link to post
Share on other sites

There are/(were?) a couple of issues with AIOM running under PHP 7.0.x & 7.1.x, but they are easily rectified, if that is the issue here.

Share this post


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

Share this post


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

Share this post


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

Share this post


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

 

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

A little while ago, I began a complete rewrite of the module that was set to add additional features (like SASS and Stylus, for example). Unfortunately, I won’t have time to work on it as fast as I’d like. But, it’s still something I’d like to do.

  • Like 3

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

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.

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 MoritzLost
      Process Cache Control
      This module provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Clear the ProCache page render cache (if your site is using ProCache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Plans for improvements
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory CHANGELOG in the repository Screenshots


    • By Macrura
      PrevNextTabs Module
      Github: https://github.com/outflux3/PrevNextTabs
      Processwire helper modules for adding page navigation within the editor.
      Overview
      This is a very simple module that adds Previous and Next links inline with the tabs on the page editor. Hovering over the tab shows the title of the previous or next page (using the admin's built in jqueryUI tooltips.)
      Usage
      This module is typically used during development where you or your editors need to traverse through pages for the purpose of proofing, flagging and/or commenting. Rather than returning to the page tree or lister, they can navigate with these links.
      Warnings
      If you are using PW version 2.6.1 or later, the system will prevent you from leaving the page if you have unsaved edits.
      For earlier versions, to avoid accidentally losing changes made to a page that might occur if a user accidentally clicks on one of these, make sure to have the Form Save Reminder module installed.
      http://modules.processwire.com/modules/prev-next-tabs/
    • By Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.2.0
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      - + - + - + - + - + - + - + - + - + - NEWS - 2020/03/19 - + - + - + - + - + - + - + - + - + - 
      There is a new Version in the pipe, that supports WebP too: 
       
      - + - + - + - + - + - + - + - + - + - NEWS - 2020/03/19 - + - + - + - + - + - + - + - + - + - 
       
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
×
×
  • Create New...