Kill run time minification?
As discussed many times: Is there any benefit in the real time minification? core.js and core.css are loaded via remote.php which actually fires up ownCloud.
Performance-wise delivering js and css from the web server is better.
As an alternative we can add minification to the release process and minify on release.
@karlitschek @butonic @icewind1991 @bartv2 @bantu @ringmaster
:+1: for minify on release
Yes, delivering JS and friends via PHP is a bad idea. Might want to checkout https://github.com/kriswallsmith/assetic
As another alternative, ownCloud could obtain these minified resources from a static location, and if the file does not exist at the location, ownCloud could generate the file.
This could be done via .htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /css/(*).css /remote.php/core.css?v=$1
remote.php would send the minified css like it does now, but it would also write the minified css to the file {$hash}.css Something could be added to cron for garbage collection.
We cant depend on .htaccess
And on mod_rewrite
I have the slight feeling two totally different things are getting mixed up.
Minification of JS and CSS is commonly referred to as reducing size by removing unnecessary characters, as well as unneeded "white space" characters like space, new line, and tab. Additionally code can be further formatted onto a single line instead of multiple.
Compression is achieved by using gzip or deflate.
Minification is definitely in the responsibility of the application and should be done as part of the release process. Whereas compression should not be in the responsibility of the application.
@karlitschek decission? :wink:
agreed. Compression is not he topic here. This is done by the webserver. We should try to not do the minification during runtime. Caching the minified version is also bad because we have to fire up the whole php/owncloud code only to load a JS file. So let's kill the minification code completely. The developers than have two option in the future. 1.) Add the non minified js file to ownCloud and use if directly. The additional load is probably minimal. And the server will be way faster. 2.) If the developer thinks that using a minified version is worth the work than the developer should commit two files (non minified and minified) and load the minified version. Note: we always need the non minified version because this is a AGPL requirement. Bu all our own minification code should be killed.
As an addendum: Developers wishing to use non-minified versions of the source for debugging purposes should look into Javascript source maps, described here: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
It may be worthwhile to add these markers to our minified files, as the overhead is small and yet debugging remains sane.
oc's minification also does concatenation of the files, which is probably a bigger speed gain then the actual minification and not something an app can do itself if it's removed from core
Looking at the requests number of requests we are making concatenating files to save extra http trips to the server seems like a good idea. But it actually it only adds complexity and makes caching core.js nearly impossible because depending on what app you load the content of core.js and core.css changes.
At a second glance it seems that we are not allowing css files to be cached. Have a look at the response headers of an arbitrary css file
HTTP/1.1 304 Not Modified
Date: Mon, 19 Aug 2013 12:10:27 GMT
Server: Apache/2.2.22 (Ubuntu)
Connection: Keep-Alive
Keep-Alive: timeout=5, max=95
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: cache
Vary: Accept-Encoding
The expires date is in the past, causing the browser to re-fetch all of the css files. Just have a look at the network tab in chromium or firefox. We also have the ?v=<hash of file> query parameter to make sure changed files get updated immediately and don't need a cache invalidation.
In the end we should completely remove the minification and the file concatenation, because it breaks the caching mechanisms inherent to HTTP. Fixing the Expires header for css files should give us all the speed improvement we need.
:+1: for killing result of premature optimization
the core.js and core.css files only depend on which apps you have enabled.
This would also have another benefit: it'd remove a case of 'library' bundling which is difficult for downstreams to deal with. as you chose to rip your minifiers out of mediawiki rather than using minifiers that are actually intended for external re-use, we have to break them out of mediawiki as separate packages ourselves, make owncloud depend on mediawiki, or let owncloud bundle them, none of which is an optimal choice.
(also, bump?)
I agree with @AdamWill This should be killed and it has the additional benefits that it reduced complexity which is always good. And it kills a dependency and a packaging problem. Who does volunteer to implement it? :-)
While we are at it: we shall kill the need to process the css files within PHP as well. E.g. delivering https://github.com/owncloud/apps/blob/master/gallery/css/slideshow.css by Apache straight takes 3 ms where processing and delivering it through PHP takes more than 600ms on localhost.
Why do we process the css? Because we want to replace the variables %webroot% and %appswebroot% see https://github.com/owncloud/apps/blob/master/gallery/css/slideshow.css#L12
We should kill these variables as well - within slideshow.css it's anyhow questionable if it's a good approach to reference the images of core - apps shall be self-contained and deliver their own images or maybe use given core css classes.
if we still want proper asset pipelining: https://github.com/kriswallsmith/assetic/
uhhhhhh ... Assetic is nice!
By the way, there seems to a problem with concatinating the js files to core.js with some apps. https://github.com/owncloud/core/issues/6480
But if you kill this whole minification and concationation stuff out of PHP this will be solved. :) So :+1:
solved in the scope of oc7