Make WordPress Core


Ignore:
Timestamp:
08/28/2025 07:54:21 AM (14 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.

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

Props jonsurrell, swissspidy, alshakero, westonruter.
Fixes #63887.

File:
1 edited

Legend:

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

    r60681 r60685  
    222222                        return;
    223223                }
     224
     225                $output .= sprintf(
     226                        "\n//# sourceURL=inline:%s",
     227                        rawurlencode( "{$handle}-js-extra" )
     228                );
    224229
    225230                if ( ! $display ) {
    … …  
    521526                        return '';
    522527                }
     528
     529                $data[] = sprintf(
     530                        '//# sourceURL=inline:%s',
     531                        rawurlencode( "{$handle}-js-{$position}" )
     532                );
    523533
    524534                return trim( implode( "\n", $data ), "\n" );
Note: See TracChangeset for help on using the changeset viewer.