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

Speculative Loading: Two <script type="speculationrules"> tags? #1910

Closed
TobiasBg opened this issue Mar 8, 2025 · 5 comments
Closed

Speculative Loading: Two <script type="speculationrules"> tags? #1910

TobiasBg opened this issue Mar 8, 2025 · 5 comments
Labels
[Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) [Type] Bug An existing feature is broken

Comments

@TobiasBg
Copy link

TobiasBg commented Mar 8, 2025

Bug Description

I just tested the Speculative Loading plugin, version 1.4.0, on WP 6.8-beta1-59953 (because I'm interested in the moderate eagerness).

Now, I might be misunderstanding something, but it doesn't seem right that the plugin adds a second <script type="speculationrules"> tag (for prerender, with moderate) in addition to the one (for prefetch with conservative) that WP 6.8 adds. I would have expected that the plugin replaces the one from WP?

This is what I'm getting in the frontend HTML:

<script type="speculationrules">
{"prefetch":[{"source":"document","where":{"and":[{"href_matches":"\/*"},{"not":{"href_matches":["\/wp-*.php","\/wp-admin\/*","\/wp-content\/uploads\/*","\/wp-content\/*","\/wp-content\/plugins\/*","\/wp-content\/themes\/ollie\/*","\/*\\?(.+)"]}},{"not":{"selector_matches":"a[rel~=\"nofollow\"]"}},{"not":{"selector_matches":".no-prefetch, .no-prefetch a"}}]},"eagerness":"conservative"}]}
</script>
<script type="speculationrules">
{"prerender":[{"source":"document","where":{"and":[{"href_matches":"\/*"},{"not":{"href_matches":["\/wp-*.php","\/wp-admin\/*","\/wp-content\/uploads\/*","\/wp-content\/*","\/wp-content\/plugins\/*","\/wp-content\/themes\/ollie\/*","\/*\\?(.+)"]}},{"not":{"selector_matches":"a[rel~=\"nofollow\"]"}},{"not":{"selector_matches":".no-prerender"}}]},"eagerness":"moderate"}]}
</script>

(The prerender with moderate works fine, according to the Chrome Dev Tools, it's just the duplicated <script> tag that I find odd. Or is that because of the slightly different "not":{"selector_matches":...} rules?)

@TobiasBg TobiasBg added the [Type] Bug An existing feature is broken label Mar 8, 2025
@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2025 Mar 8, 2025
@westonruter
Copy link
Member

westonruter commented Mar 8, 2025

Ah yes, the issue is that we haven't yet released a new version of the Speculative Loading plugin that accounts for the feature in 6.8-beta1. See #1883.

@westonruter westonruter added the [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) label Mar 8, 2025
@TobiasBg
Copy link
Author

TobiasBg commented Mar 8, 2025

Totally makes sense, my bad! I had checked the code here in the repo and was confused that this was happening despite seeing if ( function_exists( 'wp_get_speculation_rules_configuration' ) ) { -- it didn't occur to me that the wp.org version might be different to this repo...

I assume that a new release will happen in time for WP 6.8 so that this issue can probably be closed, unless it should serve as a reminder.

@westonruter
Copy link
Member

Yes, we'll be releasing the new version of the plugin in a couple weeks. I'll try to make a ZIP build of the plugin later and attach it here later today for you to use in the meantime.

@westonruter
Copy link
Member

@TobiasBg Here's a build of the plugin from trunk (at 1a7f906) you can use that includes the aforementioned PR merged: speculation-rules.zip

@TobiasBg
Copy link
Author

TobiasBg commented Mar 9, 2025

Thanks, @westonruter!

@github-project-automation github-project-automation bot moved this from Not Started/Backlog 📆 to Done 😃 in WP Performance 2025 Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) [Type] Bug An existing feature is broken
Projects
Status: Done 😃
Development

No branches or pull requests

2 participants