Skip to content

Embedded js: remove some dependency from jquery #9508

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

Merged
merged 5 commits into from
Aug 23, 2022
Merged

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Aug 17, 2022

This needs readthedocs/common#155.

Basically replacing ajax calls with the fetch API, and using the DOM API for the manipulation of elements.

Note: we need to create a rule on cloudflare to not cache the analytics endpoint,
we were previously using a hack for this (passing a random query arg). In the future, we should set this at the view level (no-cache). Already did this for .org and .com.

@stsewd stsewd requested a review from a team as a code owner August 17, 2022 04:27
@stsewd stsewd requested a review from agjohnson August 17, 2022 04:27
@@ -275,23 +296,27 @@ function attach_elastic_search_query_mkdocs(data) {
var results = data.results || [];

if (results.length) {
var searchResults = $('#mkdocs-search-results');
searchResults.empty();
let searchResults = document.getElementById('mkdocs-search-results');
Copy link
Member Author

Choose a reason for hiding this comment

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

We could also just kill the mkdocs integration, isn't currently being used (only on my test project).

Copy link
Member

Choose a reason for hiding this comment

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

I'm 👍🏼 on removing things we are not using 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this is something that we instead address with generic version of our search integration. I'm 👍 in both directions, if we aren't using the code it shouldn't hurt to keep it around either, but also happy to see unused code disappeared.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove it, and work towards shipping our livesearch as a generic JS library. The less code we have to maintain the better. 👍

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

These changes look good! It's hard to verify without a proper test suite, but this is something to keep on our radar.

@@ -275,23 +296,27 @@ function attach_elastic_search_query_mkdocs(data) {
var results = data.results || [];

if (results.length) {
var searchResults = $('#mkdocs-search-results');
searchResults.empty();
let searchResults = document.getElementById('mkdocs-search-results');
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this is something that we instead address with generic version of our search integration. I'm 👍 in both directions, if we aren't using the code it shouldn't hurt to keep it around either, but also happy to see unused code disappeared.

@stsewd stsewd requested a review from a team as a code owner August 17, 2022 19:36
@stsewd stsewd requested review from humitos and agjohnson August 17, 2022 19:36
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looking at the previous comments, I think this is good to ship. @agjohnson if you want to give it another look, go ahead, but it seems like you already reviewed it and it's 👍 with the review updates.

Also agree that we need to QA this pretty heavily, given the lack of testing 🙃

@@ -30,21 +30,6 @@ function injectFooter(data) {
}


function setupBookmarkCSRFToken() {
Copy link
Member

Choose a reason for hiding this comment

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

Ha, old school 🙃

@@ -275,23 +296,27 @@ function attach_elastic_search_query_mkdocs(data) {
var results = data.results || [];

if (results.length) {
var searchResults = $('#mkdocs-search-results');
searchResults.empty();
let searchResults = document.getElementById('mkdocs-search-results');
Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove it, and work towards shipping our livesearch as a generic JS library. The less code we have to maintain the better. 👍

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Changes look good!

@stsewd stsewd merged commit 1512ef5 into main Aug 23, 2022
@stsewd stsewd deleted the remove-some-jquery branch August 23, 2022 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants