Minify (JS & CSS) plugin for cpg1.5x Minify (JS & CSS) plugin for cpg1.5x
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Minify (JS & CSS) plugin for cpg1.5x

Started by jayhunter, May 31, 2011, 08:52:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jayhunter

Hi everyone!

For some time I used the JSmin plugin by Timos-Welt (http://forum.coppermine-gallery.net/index.php/topic,63223.0.html) but actually had to rewrite it to get it working like I wanted it to be.

Still, I needed the CSS minified, too. When I stumbled apon Minify I decided to write this plugin. It does exactly what I need, is well maintained and fast.

Description
This plugin is an integration of Minify for the Coppermine Gallery. The main goal is to save HTTP requests, bandwith and speed up page loading time by detecting CSS and Javascript files used throughout the gallery - clean, combine, compress and serve them highly optimized.

Installation
Install through plugin manager. Surf through different pages of your gallery and check the plugins configuration to enable found CSS and JavaScript files for optimization.

Known issues
When I included the js/thumbnails.js file to be minified, the filmstrip did not work as expected anymore.

This is the initial release. Please test and report any bugs you find.

Plugin in action at Home Theater Backdrops.

Cheers,
Jayhunter

Αndré

Quote from: jayhunter on May 31, 2011, 08:52:35 PM
Known issues
When I included the js/thumbnails.js file to be minified, the filmstrip did not work as expected anymore.
I haven't looked at that file nor tested your plugin yet, but do you have any suggestion how we can make it work? Maybe there's just a missing semi-colon or something similar.

jayhunter

Quote from: Αndré on June 01, 2011, 11:13:33 AM
I haven't looked at that file nor tested your plugin yet, but do you have any suggestion how we can make it work? Maybe there's just a missing semi-colon or something similar.

I have no clue why it does not work and I didn't go into the code either. This is the only file that caused trouble while testing. Even all those swf upload and several .js files from different plugins do work beautiful when included. My wildest guess is that there is a conflict between thumbnails.js and displayimage.js (obvious I guess ...) when they are loaded simultaniously, maybe the inclusion order? No idea so far ...

papukaija

I have some suggestions for your great plugin. I noticed from your demo page's source that this plugin loads Javascript first and then CSS. However, both Google and Yahoo! recommend to include CSS first and then Javascript.

This would mean that line 72 (for CSS) in codebase.php should be changed to:
$html = str_replace('<head>','<head><link rel="stylesheet" href="' . $min_file . '" type="text/css" />',$html);
and line 88 (for JS) to:
$html = str_replace('</head>', '<script type="text/javascript" src="' . $min_file . '"></script></head>',$html);

You should also remove the massive empty lines from that file, the first set starts from line 94 and the second from line 153.

jayhunter

Thanks for the suggestion papukaija.

I included the changes in my developement copy and they will be in the next release. I plan to further enrich the plugin with grouping (e.g. swfupload files separte) and sorting options (e.g. jQuery first). This might take some time though ...

Cheers,
Tobias

pols1337

/bump

I hope you're still considering releasing an updated Minify plug-in. 

netb

/bump
Any news on newer version, also have you considered loading the JS's with async or defer? :)

marcelm

Type writer of the plug-in has not logged in since two years so not much chance of a new version.