-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add sourceURL to inline script and style tags #9628
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 sourceURL to inline script and style tags #9628
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
aa0570d
to
e887b43
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Inline scripts and styles include a
@alshakero brought this to my attention. I know @jsnajdr, @sgomes, and @youknowriad also expressed interest. |
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.
Great idea!
I saw this feature recently too and thought it would be perfect for core, so thanks for adding this!
Shall I see about handling |
This handles the output of `wp_localize_script()`.
3c4e068
to
89ac596
Compare
I pushed a change to add |
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.
I tested it and tried my best to break it (new lines, */
in handle and weird characters in handle), and it worked like a charm!
TIL: New lines will make it through when used in a script handle. But the rawurlencode
took care of these.
Me too! I had this on my list to follow up on. Specifically via: https://x.com/csswizardry/status/1954863359695720623 |
What about prefixing the |
I don't feel strongly, but after reflecting I'm inclined to add it. I don't believe there are technical reasons to use a specific name or format, this should be what's easiest for people to identify. I do think there's value in using the same name as the Right now the source URLs look like this:
With the prefix and no other changes they'd be:
It seems slightly redundant in the style case |
Improve the source locations referenced by developer tooling in supporting browsers. Inline source locations are named like `inline:handle-js-after` and appear in the developer tools "sources" panel. Developed in #9628. Props jonsurrell, swissspidy, alshakero, westonruter. Fixes #63887. git-svn-id: https://develop.svn.wordpress.org/trunk@60685 602fd350-edb4-49c9-b593-d223f7449a82
Improve the source locations referenced by developer tooling in supporting browsers. Inline source locations are named like `inline:handle-js-after` and appear in the developer tools "sources" panel. Developed in WordPress/wordpress-develop#9628. Props jonsurrell, swissspidy, alshakero, westonruter. Fixes #63887. Built from https://develop.svn.wordpress.org/trunk@60685 git-svn-id: http://core.svn.wordpress.org/trunk@60021 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Improve the source locations referenced by developer tooling in supporting browsers. Inline source locations are named like `inline:handle-js-after` and appear in the developer tools "sources" panel. Developed in WordPress/wordpress-develop#9628. Props jonsurrell, swissspidy, alshakero, westonruter. Fixes #63887. Built from https://develop.svn.wordpress.org/trunk@60685 git-svn-id: https://core.svn.wordpress.org/trunk@60021 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Just a quick heads up, you may want to be aware of this. Especially at WP’s scale: https://x.com/csswizardry/status/1955262508178043002
Thanks, it sounds like we now have a technical reason to avoid the From the linked tweet:
|
#9655 removes the |
Improve the source locations referenced by developer tooling in supporting browsers. Inline source locations are named like `inline:handle-js-after` and appear in the developer tools "sources" panel. Developed in WordPress#9628. Props jonsurrell, swissspidy, alshakero, westonruter. Fixes #63887. git-svn-id: https://develop.svn.wordpress.org/trunk@60685 602fd350-edb4-49c9-b593-d223f7449a82
Trac ticket: https://core.trac.wordpress.org/ticket/63887
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.