Admidio / admidio

Admidio is a free open source user management system for websites of organizations and groups. The system has a flexible role model so that it’s possible to reflect the structure and permissions of your organization.
https://www.admidio.org
GNU General Public License v2.0
332 stars 131 forks source link

Minify CSS and JavaScript #49

Open ximex opened 9 years ago

ximex commented 9 years ago

to optimize the load of .css and .js we should minify them.

possible solution: http://gulpjs.com/ Plugins:

this all works with node.js/io.js

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/13279048-minify-css-and-javascript?utm_campaign=plugin&utm_content=tracker%2F10474012&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F10474012&utm_medium=issues&utm_source=github).
Fasse commented 9 years ago

I don't know if this is useful for our small js and css script. The css should not be minified so it's easier for people to change it and it has only 16kb. Our only js files also have less than 10kb. So in my opinion there is no need to use this for Admidio. It only increases the complexity if you want to change something.

ximex commented 9 years ago

this doesn't mean that you don't have a normal version of the css and js file. this minify process is like a build process. you still have your source code but get a binary too.

here you have your normal file like admidio.css and get a other file like admidio.min.css. if you want to change something you did this in the original admidio.css file and start the "building-process". and than we only use the *.min.css files.

advantages you could get of this are: css

PS: bootstrap use less and sass and compile it with this techniques

javascript

ECMAScript 5 is the normally known Javascript https://kangax.github.io/compat-table/es6/ (look at the top for links to ECMA 5 and 7)

(I only use ECMAScript 5 or 6 and don't like to use coffeescript etc)

by the way: do we use the normalize.css anywhere? (https://necolas.github.io/normalize.css/) Edit: ok it's already in bootstrap (http://getbootstrap.com/css/#overview-normalize)

ximex commented 9 years ago

Here my code for the gulpfile.js file to "build" the css from less (less -> autoprefixer -> minify)

// gulpfile.js

var gulp = require('gulp');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var minify = require('gulp-minify-css');
var rename = require('gulp-rename');

var pathTheme = './adm_themes/modern/';

gulp.task('css', function () {
    gulp.src(pathTheme + 'css/*.less')
        .pipe(less())
        .pipe(autoprefixer())
        .pipe(rename({
            extname: '.css'
        }))
        .pipe(gulp.dest(pathTheme + 'css/'))
        .pipe(minify())
        .pipe(rename({
            extname: '.min.css'
        }))
        .pipe(gulp.dest(pathTheme + 'css/'));
});
Fasse commented 9 years ago

But the webmaster who uses admidio and dont know about LESS or gulp should simply edit the readable admidio.css and See the result in the browser.

Thats why I dont like the minified for admidio.css

ximex commented 9 years ago

look at #80 to see what browsers we should support with autoprefixer

Fasse commented 9 years ago

We should not minify our css or js until the scripts are only so small.

ximex commented 9 years ago

But the webmaster who uses admidio and dont know about LESS or gulp should simply edit the readable admidio.css and See the result in the browser.

here i can say: the webmasters don't know anything about how the classes works e.g.

this is only an option. you could also do it in the old way. but why won't we give them an other possibility?

and for this we put in a little documentation so everyone could do this. It's nearly the same as here: http://getbootstrap.com/getting-started/#grunt

Fasse commented 9 years ago

For me it's no option to use this, because it's more work for developers, releases and webmasters. I don't want to create these files at each release. A release is a lot to do for my freetime. And you arguement that webmasters dont know anything about our css is not true. There are a lot of people who do some tweaks on our css and I dont want theme to see a minified css. I'm happy if people do something with our css and there should be no more difficults for them.

ximex commented 9 years ago

@Fasse i din't mean the css classes :wink: i mean the classes in adm_program/system/classes. I think you still not know what i'm thinking about :wink:

if we use this, the "normal users" which didn't know something about "less", "gulp" etc, they could still make changes in the normal admidio.css file. but the core developers would get a more powerful tools and language.

I think developers should go with the time of the new technologies they are coming up. In nearly all other projects i help, they use some of this technologies. I only want to make the life easier for us. And yes, at the beginning you have to learn something new. but it's really easy.

It's also possible to automate some other tasks with "gulp" etc. like making a git release, load a file via ftp on a server, ...