Make WordPress Core


Ignore:
Timestamp:
09/08/2025 11:25:40 AM (2 months ago)
Author:
jonsurrell
Message:

Script Loader: Add sourceURL to inline scripts and styles.

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.

This is the second attempt to add sourceURL comments. The first attempt in [60685] was reverted due to an issue with script concatenation that has been addressed.

Developed in https://github.com/WordPress/wordpress-develop/pull/9672.

Follow-up to [60685], [60690].

Props jonsurrell, westonruter, wildworks, peterwilsoncc, johnbillion, tobiasbg.
Fixes #63887.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-styles.php

    r60690 r60719  
    336336        if ( empty( $output ) ) {
    337337            return false;
     338        }
     339
     340        if ( ! $this->do_concat ) {
     341            $output[] = sprintf(
     342                '/*# sourceURL=%s */',
     343                rawurlencode( "{$handle}-inline-css" )
     344            );
    338345        }
    339346
Note: See TracChangeset for help on using the changeset viewer.