Move embed-optimizer-lazy-load script to JS file#1601
Move embed-optimizer-lazy-load script to JS file#1601westonruter merged 3 commits intoWordPress:trunkfrom
Conversation
plugins/embed-optimizer/hooks.php
Outdated
| return <<<JS | ||
| const lazyEmbedsScripts = document.querySelectorAll( 'script[type="application/vnd.embed-optimizer.javascript"]' ); | ||
| const lazyEmbedScriptsByParents = new Map(); | ||
| $script = file_get_contents( __DIR__ . '/embed-optimizer-lazy-load.js.js' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request. |
There was a problem hiding this comment.
I don't think this file needs to be prefixed with embed-optimizer-. Just lazy-load.js is sufficient. Also, I see you've duplicated the .js at the end.
| $script = file_get_contents( __DIR__ . '/embed-optimizer-lazy-load.js.js' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request. | |
| $script = file_get_contents( __DIR__ . '/lazy-load.js' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request. |
There was a problem hiding this comment.
Per below, let's rename this to just lazy-load.js.
There was a problem hiding this comment.
Thanks for the suggestion. I have made the requested changes.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| lazyEmbedParent | ||
| ); | ||
| const embedScript = | ||
| /** @type {HTMLScriptElement} */ document.createElement( |

Summary
Fixes #1600
Relevant technical choices