-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Lazy Loading for Homepage Images and Check script #5998
Add Lazy Loading for Homepage Images and Check script #5998
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shivamgupta2020 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for knative ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
The check script should do these:
This script should be running in a Github action. I would recommend this approach:
|
Thanks, @aliok , for the suggestions. I’m currently working on the script part and will include all your suggestions in a new commit as soon as possible. |
Should the script also run for v1.13, v1.12, and the development folder present in the "site" folder? |
import os | ||
import sys | ||
import subprocess | ||
from bs4 import BeautifulSoup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a possibility to use standard Python libraries for parsing HTML files?
What's your opinion here @shivamgupta2020 ? We need to instruct people to install some dependencies if we go with BeautifulSoup. However, we might have some non-standard HTML content that might not be parseable with standard Python libraries.
Let's ask @knative/productivity-leads and @cardil specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliok, I experimented with HTMLParser and IXML for parsing HTML files, but encountered numerous errors and incomplete parsing. Therefore, I switched to BeautifulSoup. I also think we should gather opinions from others on this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check_img_lazy.py
Outdated
def build_website(): | ||
"""Build the website using the specified command.""" | ||
try: | ||
subprocess.check_call(['./hack/docker/test.sh']) | ||
except subprocess.CalledProcessError as e: | ||
print(f"Website build failed: {e}") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave this part out of the script.
This script will eventually run in a GitHub Actions workflow:
- Build the website
- Run the script
- If there are images w/o
loading=lazy
, script should fail - If there are no images, script should exit successfully
- If there are images w/o
Can you put the script in a GitHub actions workflow please?
Also, we need to document this change with instructions. In the relevant section here: https://github.com/knative/docs/blob/main/contribute-to-docs/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure, I will remove the build function from the script.
I will look into the GitHub action workflow and add the script as soon as possible.
build_website() | ||
|
||
|
||
base_dir = 'site' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this configurable. Script should receive the directories to check HTML files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function runs on the "site" folder because this folder is created after the build command. That's why I set base_dir = 'site.'
Why do we need to make it configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Let's leave as is. I need to check this later.
e4d6861
to
0b192e9
Compare
0b192e9
to
34b7d52
Compare
I've created the workflow file as @aliok suggested. Currently, most of the images on the website are not lazy-loaded, resulting in many errors. Could you please check the script output on your local machine to verify it's working as expected? Also, please review the workflow code to ensure it's implemented correctly. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This Pull Request is stale because it has been open for 90 days with |
Fixes #5981
Proposed Changes