Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts integration query argument #439

Open
vralle opened this issue Mar 7, 2021 · 1 comment
Open

Scripts integration query argument #439

vralle opened this issue Mar 7, 2021 · 1 comment

Comments

@vralle
Copy link

vralle commented Mar 7, 2021

Hi!
I am reviewing WP_Service_Worker_Scripts_Integration->register()

The method uses WP Core filter script_loader_src and then adds the version value to the url. I have a question about the sequence of these actions.

The filter script_loader_src can be used anywhere for cleanup url. In this case, the cleaned url without additional arguments are included in the page markup. While the plugin will continue to use url with an additional argument.

Unfortunately, I did not have time to delve into the knowledge of how SW works to determine the correctness of this behavior. However, if the script preload links differ from the script markup links, this behavior results in an error.

If the filter fire last, the url may be the same.

WP Core reference:
https://github.com/WordPress/WordPress/blob/52679edbffe1a28cf7fce54ab2077f299c8cf27e/wp-includes/class.wp-scripts.php#L375-L382

@westonruter
Copy link
Collaborator

Hi there. Yeah, I actually do not recommend using WP_Service_Worker_Scripts_Integration. As noted in the wiki, the integrations are experimental and I intend to deprecate them (#403). A problem with WP_Service_Worker_Scripts_Integration is that it precaches scripts even if those scripts never get used. It is normally preferable rather to use the runtime cache to instead cache scripts that are actually used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants