forum.coppermine-gallery.net

Support => cpg1.5 plugins => cpg1.5.x Support => cpg1.5 plugin contributions => Topic started by: jayhunter on May 31, 2011, 08:52:35 pm

Title: Minify (JS & CSS) plugin for cpg1.5x
Post by: jayhunter on May 31, 2011, 08:52:35 pm
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 (http://code.google.com/p/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 (http://www.htbackdrops.com).

Cheers,
Jayhunter
Title: Re: Minify (JS & CSS) plugin for cpg1.5x
Post by: Αndré on June 01, 2011, 11:13:33 am
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.
Title: Re: Minify (JS & CSS) plugin for cpg1.5x
Post by: jayhunter on June 01, 2011, 05:48:47 pm
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 ...
Title: Re: Minify (JS & CSS) plugin for cpg1.5x
Post by: papukaija on July 03, 2011, 05:27:58 pm
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 (http://code.google.com/intl/fi/speed/page-speed/docs/rtt.html#PutStylesBeforeScripts) and Yahoo! (http://developer.yahoo.com/performance/rules.html#css_top) recommend to include CSS first and then Javascript.

This would mean that line 72 (for CSS) in codebase.php should be changed to:
Code: [Select]
$html = str_replace('<head>','<head><link rel="stylesheet" href="' . $min_file . '" type="text/css" />',$html);
and line 88 (for JS) to:
Code: [Select]
$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.
Title: Re: Minify (JS & CSS) plugin for cpg1.5x
Post by: jayhunter on July 03, 2011, 07:10:01 pm
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
Title: Re: Minify (JS & CSS) plugin for cpg1.5x
Post by: pols1337 on February 04, 2012, 09:12:34 am
/bump

I hope you're still considering releasing an updated Minify plug-in. 
Title: Re: Minify (JS & CSS) plugin for cpg1.5x
Post by: netb on September 27, 2015, 03:36:23 am
/bump
Any news on newer version, also have you considered loading the JS's with async or defer? :)
Title: Re: Minify (JS & CSS) plugin for cpg1.5x
Post by: marcelm on September 29, 2015, 05:37:09 pm
Type writer of the plug-in has not logged in since two years so not much chance of a new version.