MyBB Community Forums

Full Version: Minify CSS and JS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This has been discussed in a different thread already but is not yet announced as planned feature. I'd like to see an automated combination, minifying and gzipping of all CSS and JS files as described here:


(2012-12-31, 07:33 PM)faviouz Wrote: [ -> ]In general I think it would be a good idea to have a more unified assets manager (most PHP frameworks offer one anyway) that would also allow some sort of a build process, i.e. concatenate files together and minify/gzip them as much as possible. You would then have a single file for all your styles and another for all the JavaScript (i.e. less HTTP requests), which would be nice for deploying your site to users (as long as you don't go around editing styles and scripts too often).

Thanks!
Quote:In order to aid the process of compiling our SASS files and combining our JavaScript modules, we’re making use of the gulp.js build system. This system compiles our SASS stylesheets into CSS, saves them and then minifies then into “*.min.css” files for use in the main theme. It also combines all of the JavaScript files (including vendor scripts such as jQuery) and minifies them too, along with optimising all of the images used by the theme.
http://blog.mybb.com/2015/05/30/2-0-dev-post-3/
CSS is already minified in 1.8 (though not combined).

The base theme for 2.0 is being developed with gulp.js as part of the workflow to minify and combine both CSS and JS, and to optimize any images. We will likely be expanding this to user themes and JS, though we have not yet designed the implementation or the way it will work yet.
So this can be moved to planned features in this case (there is no thread about it in the 2.0 section yet, sorry I missed that blog post Stefan).
Hi,

Your feature suggestion has been accepted as a planned feature to be implemented in MyBB 2.0. Thanks for your contribution!
what about combining the CSS in 1.8, instead of making many calls to small CSS files consuming server requests?

Can there be a function to to append all the CSS and output the CSS to single flat file or cache?
Combining CSS into a single URL may hinder some caching. As an example, global.css is included in all pages, so its content would have to be downloaded (instead of using a cache) for each page type.

I would also like some configuration to not minimize CSS and JS while I am tweaking themes and plugins.
It would be nice to have both JS and CSS in the backend as data entries.....like CSS cascading as is now.....the developers just need a function to pull them out of DB, cache them as index.css, forumdisplay.css and deliver the exact named file to the correct location Toungue

for instance:

Quote:global.css
Attached to all pages
bootstrap-fixes.css
Attached to all pages
css3.css
Attached to all pages

should all be in global.css

Quote:usercp.css
Attached to usercp.php, usercp2.php and private.php

each of these pages should have an extra css for page specific: usercp.php.css, usercp2.php.css, private.php.css


EDIT: you can pretty much use Global Templates
Used by all themes

as a JS repository
MyBB 2.0 is completely different, talking about 1.8 here makes no sense...