This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WP-r55888: Script Loader: Improve performance of inlined styles (#272)
* WP-r55888: Script Loader: Improve performance of wp_maybe_inline_styles function. The `wp_maybe_inline_styles` function is called twice on the average page load. On it's second run however, it did not check to see if the style had already been processed on the first run. This resulted in calling `filesize` and `get_file_contents` unnecessarily, which was bad for performance. Now, the loop around the queued styles, checks to see if the source is set to false, meaning it has already been processed. This change also replaces calls to `filesize` with the core function `wp_filesize`, which improves extensibility. WP:Props spacedmonkey, flixos90, peterwilsoncc, joemcgill. Fixes https://core.trac.wordpress.org/ticket/58394. Conflicts: - tests/phpunit/tests/dependencies/styles.php --- Merges https://core.trac.wordpress.org/changeset/55888 / WordPress/wordpress-develop@582ddb82f4 to ClassicPress. * Fix merge conflicts and use css file from repo * WP-r55909: Script Loader: Add a check to see in style is registered in wp_maybe_inline_styles. Add a check in `wp_maybe_inline_styles` to check that style is registered before processing items in queue. It is possible that developers may have called `wp_deregister_style`, unregistering style but the style still be in the queue to be processed. Without this check, typing to access the `src` property would result in a notice error. Follow on from https://core.trac.wordpress.org/changeset/55888. WP:Props spacedmonkey, flixos90, dd32, kebbet. See https://core.trac.wordpress.org/ticket/58394. --- Merges https://core.trac.wordpress.org/changeset/55909 / WordPress/wordpress-develop@559e6cecf4 to ClassicPress. * Use smaller src css for testing purposes --------- Co-authored-by: Jonny Harris <[email protected]>
- Loading branch information