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

Fix unnecessary load of images when parsing the document text for search function. #8343

Merged

Conversation

janvojt
Copy link
Contributor

@janvojt janvojt commented Oct 27, 2020

Feature or Bugfix

  • Bugfix

Purpose

Avoid unnecessary traffic caused by loading many (or all) documentation images unnecessarily. In some cases, avoid unnecessary 404 errors.

Detail

The issue was, that when searching, new element with all the HTML content
was created. This caused loading of all images in the background. However, in
the end, these images are stripped from search result anyway, so there is no
point in loading them.

In cases where images were included in HTML files in a different directory from
search.html, this behaviour was even causing 404 errors because of wrong relative URLs.

This commit fixes the issue by creating virtual document and using that as the owner
document of temporary meta-element used for searching and parsing purposes.
The virtual owner document causes browser to not load the images.

…rch function.

The issue was, that when searching, new element with all the HTML content
was created. This caused loading of all images in the background. However, in
the end, these images are stripped from search result anyway, so there is no
point in loading them.

In cases where images were included in HTML files in a different directory from
search.html, this behaviour was even causing 404 errors because of wrong relative URLs.

This commit fixes the issue by creating virtual document and using that as the owner
document of temporary meta-element used for searching and parsing purposes.
The virtual owner document causes browser to not load the images.
@tk0miya tk0miya added this to the 3.3.0 milestone Oct 27, 2020
@tk0miya tk0miya merged commit 9957526 into sphinx-doc:3.x Oct 27, 2020
@tk0miya
Copy link
Member

tk0miya commented Oct 27, 2020

Merged. Thank you for your contribution!

tk0miya added a commit that referenced this pull request Oct 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants