primefaces / primefaces

Ultimate Component Suite for JavaServer Faces
http://www.primefaces.org
MIT License
1.81k stars 762 forks source link

Static Resources in Primefaces are uncompressed ! #3116

Closed ssibitz closed 6 years ago

ssibitz commented 6 years ago

When i currently build the Primefaces6.2-SNAPSHOT i can see that all static resources (Stylesheet's/Javascript's and also large Images) are uncompressed. This unnecessarily results in a very large JAR-File and a bad result in Google's PageSpeed of your current PrimeFaces ShowCase:

2017-12-28 12_12_04-fotos

2017-12-28 12_12_27-primefaces showcase

I think that there is a bug in your maven-build-system because the bug only exist's when i am building Primefaces but not Primefaces-Extensions. The difference between the build's ?

Primefaces is using old Maven-Plugin's and a old version's of the YUI-Compressor which is currently deprecated by yahoo and can only compress stylesheet's correct - javascript's are not compressed right and also the aggregates are not working right with compression.

Primefaces-Extensions is using a own maven-plugin which makes the best compression by using the last YUI-Compressor available/working and also the Google Closure compiler for JavaScript compressing. It seems that this is also working with aggregated files because the single script's/stylesheet's are compressed before and then concentrated to one.

So also Primefaces should use the Primefaces-Extensions Plugin https://github.com/primefaces-extensions/primefaces-extensions.github.com/wiki/Maven-plugin-for-web-resource-optimization for optimizing the static css/js resources and also for aggregates because here it's working right !

tandraschko commented 6 years ago

Sorry but this is invalid, check the docu: https://github.com/primefaces/primefaces/wiki/Building-From-Source

tandraschko commented 6 years ago

AND: i don't care about image size in the showcase... It's not built for high performance. Also thats an issue of the showcase, not of primefaces.

ssibitz commented 6 years ago

The showcase is only an example for that, so you can do it with any other project including the primefaces-jar file !

Please compress your static resources (script's and stylesheet's) as any other web-project's are doing it by checking your build-script of Primefaces !

This is currently not done - also when re-building the whole primefaces project like you described in the wiki - nothing happens to the static resources: They are packed as they are in original but only aggregated together to one file and: Uncompressed !

Please check your build-scripts because that's a real issue in production because i don't want to re-check all your static resources and re-pack them full compressed into the primefaces-jar file i buyed from you !!

ssibitz commented 6 years ago

I am talking about compressing this resources in Primefaces-6.1.10 (The same in Primefaces 6.1.11)

primefaces-6 1 10

... and the same issue when building the newest version Primefaces 6.2-SNAPSHOT: primefaces-6 2

The most of them (and the biggest ones) are static resources by Primefaces that are not compressed. Not in PRO/ELITE and not in Community-Edition !

The other part are my own script's/stylesheet's which are not static or coming from other used libraries which i try to remove or in plan to be removeed, so please ignore them ...

tandraschko commented 6 years ago

Did you check the section about resource minification in the link i posted? Note: i only talk about trunk, i dont manage elite releases but melloware created a ticket for it.

ssibitz commented 6 years ago

Yes, i already know the link you posted, but building primefaces with the maven-parameter's: clean install -Prelease -Dmaven.javadoc.skip=true -Dgpg.skip=true does not compress anything in the resulting static resources as you can see on the images:

For example taking a special look on the components.js from primefaces: Here are all the script's combined to one (aggregatet) but nothing of them is compressed/minimized and also not the aggregated result which result's in: Primefaces 6.1.10 - Compression of "components.js" could save 311.2KiB (79%) or in: Primefaces 6.2-SNAPSHOT - Compression of "components.js" could save 657.6Kib (84%)

ssibitz commented 6 years ago

I will try to add the Maven plugin for web resource optimization from the primefaces extensions project to the primefaces maven-build-script after the static resources has been aggregated (but not compressed/minimized) to minimize them before package them into the jar-file...

I will check the sizes before and after and give you a feedback...

tandraschko commented 6 years ago

Sorry but works fine for me. Just using "mvn clean package -Prelease" and open the JAR - following file is compressed for me: /META-INF/resources/primefaces/components.js

tandraschko commented 6 years ago

JFYI: i'm using mvn 3.3.9 on oracle JDK 1.8.0_121 on a mint machine ;)

ssibitz commented 6 years ago

Hmm - It seems that the Google-PageSpeed wasn't updated for a long time, so i have the result's now:

1.) Enable compression means (in my case) that the browser isn't currently accepting the GZIP-Header - Activated on wildfly but ignored by browser !! I can activate/overwrite this by using the Omnifaces GZIP-Filter. You eventually also should use this in your showcase by only adding them to the web.xml / pom.xml http://showcase.omnifaces.org/filters/GzipResponseFilter

2.) Google Page Speed shows always a smaller Resource-File's than your's because: Google always remove all comment's, newlines and spaces so the minimized files by google are always smaller than your compressed/minimized: You always add a newline for each file aggregate and keep the comment's of all aggregates as they are as "Must-Comment's"

Please make the Comment's minimizeable from the JavaScripts/Stylesheets because the header's are not needed in production. Please also remove the newline for each aggregate because this is also a unneeded setting.

By changing the comments from: /*! to /* they will no longer be included in production / aggregation-files and the files are smaller, so really minimized by YUI-Compressor !

tandraschko commented 6 years ago

removing newlines brings maybe 1kb in the all of our resources, i won't do this ;) changing comments removes ~10-15kb but we have to adjust third party libraries, so probably i won't do this, too as the result isn't big compared to all of our resources.

ssibitz commented 6 years ago

I am not talking about removing this comment lines in the source-code but setting them to removeable and not fix when building the aggregates. No end customer will need endless comment's from third party lib's in static resource files in a buyed libray - only once at the header but not x times !

Yes, i know we are talking about peanut's in size against your primefaces library, but keep in mind that currently saving all unnessesary thing's over a slow network will keep a user away from leaving the site !

Here is the example of what space can be saved only by removing this unnessesary comment's: core.js -> 31328 Bytes core.min.js ->30032 Bytes = -4,14 % Size

components.js -> 404828 Bytes components.min.js -> 392016 Bytes = -3,16 % Size

tandraschko commented 6 years ago

Modify third party libraries is IMO something that should only be done for hotfixes.

So the only real solution is to replace our plugin by a better one. If you have time to do this, feel free to provide a PR. It should be uncompressed in a normal build and compressed when running with -Prelease.

I can't even see any comments in core.js (in the generated jar) ;)