Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused assets and optimize loading #50

Merged
merged 5 commits into from
Dec 26, 2020
Merged

Remove unused assets and optimize loading #50

merged 5 commits into from
Dec 26, 2020

Conversation

ferferga
Copy link
Member

@ferferga ferferga commented Aug 2, 2020

Remove unused assets and use SVGs for all the graphic resources used, reducing bandwidth usage and removing the artifacts that appear when the logo, for example, is being downloaded when the app is launched.

Comment on lines +2 to +10
<!-- ***** BEGIN LICENSE BLOCK *****
- Part of the Jellyfin project (https://jellyfin.media)
-
- All copyright belongs to the Jellyfin contributors; a full list can
- be found in the file CONTRIBUTORS.md
-
- This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
- To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
- ***** END LICENSE BLOCK ***** -->
Copy link
Member Author

@ferferga ferferga Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we remove this block in both files?

We already have it in the original jellyfin-ux repo and we might save a few kilobytes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds fine by me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Licensing stuff is not my strong side though

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, I think someone on the general matrix chat mentioned that we should have licensing at the start of all the files. Hopefully someone with more knowledge of licensing can help.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the SVG files should be optimized during build, which would remove the licensing block anyway.

I don't know the build process for this repo, but I'm guessing it's packing everything with Webpack, so using something like image-webpack-loader, which uses imagemin (the same tool we use to optimize images on jellyfin-web) should do the trick.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshuaboniface Leaving and removing the blocks in production in 24ede02

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShareAlike also mandates that any derivative is also properly licensed under the same license so it should be noted on the license/about page. Cause even the minified SVG is STILL CC-BY-SA.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EraYaN Adding a header at the bottom of the LICENSE.md file with a copy-paste of the license included in the SVG is enough?

Sorry, I'm not a license expert

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass options to the SVGO plugin of Imagemin to keep comments. The option in question is removeComments (true by default)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with removeComments=false

@ferferga
Copy link
Member Author

ferferga commented Aug 5, 2020

@jellyfin/web Not sure if this is the best method for optimizing images using webpack (I'm a noob with webpack and no way I get file-loader and rest of goodies to work), feel free to commit and improve this.

It works™ at least :P

@YouKnowBlom
Copy link
Contributor

LGTM. Let me know when the licensing stuff is figured out.

@MrTimscampi you might want to take a look at this as you're better at webpack than me :p.

["svgo", {
plugins: [
{
removeViewBox: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
removeViewBox: false
removeComments: false,
removeViewBox: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ensure that the license is kept.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change

const webpack = require("webpack");

let config = {
context: path.resolve(__dirname, "src"),
entry: "./app.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
path: path.resolve(__dirname, "dist")
},
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin([{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be replaced by proper injection at some point for cache busting. More info here: https://webpack.js.org/guides/output-management/

@@ -1,22 +1,38 @@
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ImageminPlugin = require("imagemin-webpack");
const webpack = require("webpack");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused dependency

@hawken93
Copy link
Contributor

I have rebased this over at https://github.com/hawken93/jellyfin-chromecast/tree/optimize-loading

Copy link
Contributor

@hawken93 hawken93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ferferga ferferga merged commit c1589ab into jellyfin:master Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants