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

ENH prevent default type in script tag #11446

Open
wants to merge 1 commit into
base: 6
Choose a base branch
from

Conversation

lerni
Copy link
Contributor

@lerni lerni commented Oct 27, 2024

Description

For 6 application/javascript should be gone in script tags. A refactored Requirements_Backend, that allows nonce (CSP) or flat attributes[], as suggested #9910 (comment) would be preferable. Simply removing it is a minimal change, but improves the current situation.

Manual testing steps

Check the HTML source; the type attribute should no longer be present on the <script> tags.

<script src="//code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="/_resources/themes/simple/javascript/script.js?m=1718845897"></script>

instead of

<script type="application/javascript" src="//code.jquery.com/jquery-3.7.1.min.js"></script>
<script type="application/javascript" src="/_resources/themes/simple/javascript/script.js?m=1718845897"></script>

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@GuySartorelli
Copy link
Member

GuySartorelli commented Oct 30, 2024

Thanks for submitting this!

I've linked an open issue that seems relevant. We don't track PRs attached to closed issues, because closed issues can't go through the columns in our issue tracker.

While looking around for information (since the issues just state HTML5 doesn't need it, but don't provide any source), almost everything I found points to rfc9239 and say we should be using text/javascript now.

Can you please either update this to text/javascript or else explain why it should be specifically not given a type?

Please also update the commit prefix to ENH as it isn't affecting the APIs.

If you'd be willing to update other current references to application/javascript in the codebase as well that would be awesome, but isn't strictly necessary.

@lerni lerni changed the title API prevent default type in script tag ENH prevent default type in script tag Nov 5, 2024
@lerni
Copy link
Contributor Author

lerni commented Nov 5, 2024

Thank you for the feedback. In HTML5 the <script> element's type attribute defaults to "text/javascript" if it's omitted or an empty string is used.

I am open to update other instances of application/javascript in the codebase and 'll also have a crack at the failing tests. But what do you think - remove or change?

@michalkleiner
Copy link
Contributor

I'll remove it if the new value is the same as the default when omitted, less bytes transferred.

@GuySartorelli
Copy link
Member

GuySartorelli commented Nov 5, 2024

I don't think there's enough bytes there to make a meaningful difference 😅 but if best practice is to omit the value, we should follow that practice.
Thank you for the thorough response and references @lerni!

@michalkleiner
Copy link
Contributor

It's like saving a dollar on a million dollar car. One instance is insignificant, over a million cars it's a million. Less burnt coal and oil in the world.. you can definitely see the impact of this 😄

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.

3 participants