Skip to content

Remove jQuery #538

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 1 commit into from
Jan 17, 2018
Merged

Remove jQuery #538

merged 1 commit into from
Jan 17, 2018

Conversation

sorin-davidoi
Copy link
Contributor

@sorin-davidoi sorin-davidoi commented Jan 12, 2018

This is based on #535 for two reasons:

  • I assumed that Improve accessibility #535 is likely to be (eventually) merged, so I can rebase this later against master in that case
  • Make it easier for reviewers to test both of them at the same time

Depending on which browsers we need to support (couldn't find them listed), we might need the following polyfills:

I couldn't test the changes in editor.js.

Reduces JavaScript payload size from 229.88 KB to 197.91 KB (measured on book-example). Helps address #475.

@Michael-F-Bryan
Copy link
Contributor

Depending on which browsers we need to support (couldn't find them listed)

I don't believe we've got a proper list of supported browsers. My perception is that the vast majority of our users are going to be developers or computer-savvy people, and as a very broad rule those sorts of people tend to use a fairly up-to-date version of Chrome or Firefox. If we can support IE then that's awesome, but if it requires large amounts of effort or hacky band-aid solutions to do then I'll leave the decision up to the developer...

@sorin-davidoi
Copy link
Contributor Author

Well, ideally we would only load the polyfills for the browsers that need it (feature-detection) - but that is non-trivial without a build system (e.g. webpack). A simpler solution would be to just https://polyfill.io/v2/docs/. What do you think?

@sorin-davidoi
Copy link
Contributor Author

I see that crates.io uses Google Analytics. Assuming there is a significant overlap between the audiences, maybe @carols10cents could share some insights about browser usage to guide this decision?

@sorin-davidoi
Copy link
Contributor Author

sorin-davidoi commented Jan 15, 2018

Actually, crates.io does not support IE. I guess we should follow RFC 1985 as well?

@steveklabnik
Copy link
Member

I came to this thread to post RFC 1985.

@sorin-davidoi
Copy link
Contributor Author

sorin-davidoi commented Jan 15, 2018

Rebased against master, ready for review.

let editor = ace.edit(this);


Arom.from(document.querySelectorAll('.editable')).forEach(function(editable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is Arom? Is this supposed to be Array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, fixed 👍

@projektir
Copy link
Contributor

Have you tested this code? Specifically, did you test that the Ace Editor boxes still work?

@sorin-davidoi
Copy link
Contributor Author

I mentioned in the description that the changes in editor.js have not been tested (couldn't manage to trigger the codepath - it does not even load the file in the browser). What variables need to be toggled to enable the functionality?

@sorin-davidoi
Copy link
Contributor Author

Apparently, I've missed #521 - just tested and it works fine from what I can tell.

@projektir
Copy link
Contributor

Yes, the Ace editor is not yet documented, which is my bad! Some settings need to be enabled for it to work.

Generally, I test by running mdBook on the Rust by Example book, since that's what Ace editor was added for originally in the first place, so it's all setup there. I've just tested it with your branch and it seems to be working fine. 😊

@Michael-F-Bryan
Copy link
Contributor

I just checked it out on my machine and I think there's an issue with the code expansion/hiding feature.

For example, on this page, here's what it looks like collapsed (the default):

screenshot_2018-01-16_193604

Then hit run and you can see what it prints out:

screenshot_2018-01-16_193619

Expanded:

screenshot_2018-01-16_193627


This is what it's actually meant to look like when expanded:

screenshot_2018-01-16_193914

@sorin-davidoi
Copy link
Contributor Author

@Michael-F-Bryan Thanks, fixed! Sidenote, I really hate how you never know whether you are operating on a single element or on an array in jQuery (in this case, I assumed single element, so only the first hidden line was toggled).

@sorin-davidoi sorin-davidoi mentioned this pull request Jan 16, 2018
@projektir
Copy link
Contributor

Ah, blast, I didn't check code expansion, good catch @Michael-F-Bryan.

@Michael-F-Bryan
Copy link
Contributor

I don't think there were any other noticeable bugs/regression. @sorin-davidoi, do you think this is ready to merge?

@sorin-davidoi
Copy link
Contributor Author

Yes, I would say so.

@Michael-F-Bryan Michael-F-Bryan merged commit 7b356b7 into rust-lang:master Jan 17, 2018
@sorin-davidoi sorin-davidoi deleted the remove-jquery branch January 17, 2018 23:29
@sorin-davidoi
Copy link
Contributor Author

Is jQuery part of the official mdBook API? I'm thinking that this (and possibly #550) may be breaking scripts people placed in additional-js.

@Michael-F-Bryan
Copy link
Contributor

Is jQuery part of the official mdBook API?

I don't think we've ever said it's guaranteed to be loaded, it just happens to be because we use it internally. I'm going to say that people should make sure they explicitly load jQuery if they need it, plus this PR will be part of a major semver bump, so people shouldn't be surprised if they need to update their additional-js... Does that sound reasonable?

Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 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.

4 participants