[wp-trac] [WordPress Trac] #63887: Add sourceURL to inline scripts and styles
WordPress Trac
noreply at wordpress.org
Fri Aug 29 18:09:01 UTC 2025
#63887: Add sourceURL to inline scripts and styles
--------------------------------------+------------------------------
Reporter: jonsurrell | Owner: jonsurrell
Type: enhancement | Status: reopened
Priority: normal | Milestone: 6.9
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: javascript, css
--------------------------------------+------------------------------
Comment (by westonruter):
I recall this issue coming up in the past in relation to inline `//`
comments being used in some inline scripts, where some naïve
minification/concatenation logic would remove newlines, causing the
comment to comment-out the initial line of the subsequently-concatenated
script. If all of the scripts were adding the `sourceURL` comment with
multi-line comments like was done for CSS, then this should fix the issue.
Alternatively, a newline could be printed at the end of the inline
comment, which should fix the issue with `load-scripts.php`.
So instead of:
{{{#!php
<?php
$output .= sprintf(
"\n//# sourceURL=%s",
rawurlencode( "{$handle}-js-extra" )
);
}}}
Do:
{{{#!php
<?php
$output .= sprintf(
"\n/*# sourceURL=%s */",
rawurlencode( "{$handle}-js-extra" )
);
}}}
Or:
{{{#!php
<?php
$output .= sprintf(
"\n//# sourceURL=%s\n",
rawurlencode( "{$handle}-js-extra" )
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63887#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list