Skip to content

Conversation

@honzajavorek
Copy link
Collaborator

Optimizing images of the Python course with optimizt. The original images will stay in the Git history forever, the damage has been done, but at least we can improve the future experience of the readers of the docs.

Not sure if we could automate this, I guess the only way to do it would be a sort of pre-commit check. I doubt there's a GitHub Action which would optimize images and then automatically rebase the branch to get rid of the old ones. Anyway, that's a challenge for a different day, this is just a small PR with a simple and straightforward manual improvement.

@honzajavorek honzajavorek added the t-academy Issues related to Web Scraping and Apify academies. label Nov 25, 2024
Copy link
Contributor

@TC-MO TC-MO left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@vdusek vdusek left a comment

Choose a reason for hiding this comment

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

thanks 🙂

@B4nan
Copy link
Member

B4nan commented Nov 25, 2024

Docusaurus is/should be optimizing the images for us automatically, via https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-ideal-image

Can you provide some links where we have large images? Maybe we just need to configure it.

Also, we could remove them from the git history, there are ways, as long as we are fine with rewriting all the git hashes, which sounds ok for this repository.

I recall this one: https://rtyley.github.io/bfg-repo-cleaner/

@honzajavorek
Copy link
Collaborator Author

Can you provide some links where we have large images? Maybe we just need to configure it.

@B4nan I didn't do proper research, my claims are based solely on the fact that I uploaded large images previously and smaller should be better 😄 I didn't realize there could be optimization already employed somewhere. Maybe it's not an issue for the reader then?

But when I download the GIF from https://docs.apify.com/academy/scraping-basics-python/getting-links, it's 3.9 MB, which is the same size as in the repo. Not sure it that's getting optimized. I reduced it to 1.8 MB.

It's probably a good practice to add optimized images to the repo, because the sizes could add up over time, but we're talking about small numbers, so I wouldn't make it a hard rule or stress very much about it - dunno. As far as my additions are concerned, it's savings <5MB. I don't think we should bother removing them from git history and rewriting the hashes for everyone because of this.

@B4nan
Copy link
Member

B4nan commented Nov 25, 2024

Maybe it's not an issue for the reader then?

It shouldn't be. But large size of the git repository is something to pay attention to - on the other hand, replacing large images with smaller ones will only make the git repo size larger unless we use a tool like BFG to remove them from the git history.

But when I download the GIF from docs.apify.com/academy/scraping-basics-python/getting-links, it's 3.9 MB, which is the same size as in the repo. Not sure it that's getting optimized. I reduced it to 1.8 MB.

Well, that is a small image when it comes to resolution. I think docusaurus only deals with large resolutions, also not sure if it even considers gifs to begin with.

Copy link
Member

@B4nan B4nan left a comment

Choose a reason for hiding this comment

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

anyway, lets merge this one, no problems with that

@honzajavorek
Copy link
Collaborator Author

honzajavorek commented Nov 25, 2024

replacing large images with smaller ones will only make the git repo size larger

Yup, that's why I'd close this PR if I could verify that the optimization for users happen. TBH I almost did it, but then tried to download the GIF and see what's its production website size.

@honzajavorek honzajavorek merged commit bc9a6e8 into master Nov 25, 2024
7 checks passed
@honzajavorek honzajavorek deleted the honzajavorek/optimize-images branch November 25, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-academy Issues related to Web Scraping and Apify academies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants