Astra shows “‘#ssf=…’ is not a valid selector” in the console
On a site running the Astra theme, opening a filtered link that ends in #ssf=... can log an uncaught JavaScript error in the browser console. The error comes from Astra’s Smooth Scroll to ID feature, not from Super Speedy Filters, and the filters keep working: the products, the active filters and the counts all load as normal.
The only thing the error stops is Astra’s own attempt to scroll the page to an element named in the address. A #ssf= value names filter state, not an element, so there is nothing to scroll to in the first place.
What you see
The error appears in the browser’s developer console, or in a JavaScript error-monitoring service such as Sentry, about three quarters of a second after the page loads. In Chrome and Edge it reads:
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '#ssf=color/black/size/m/' is not a valid selector.
Firefox and Safari word it slightly differently, but every version quotes the #ssf= part of the address and says it is not a valid selector. The part after #ssf= is whatever filters were active, so it might read #ssf=size/m/ or #ssf=brand/acme/colour/red/ on your store.
It happens when a page loads with #ssf= in its address: a shared or bookmarked filter link, a reload, or a visitor arriving from a deep filter URL that Super Speedy Filters redirected to an archive page. Clicking filters on an open page does not trigger it.
Why it happens
Super Speedy Filters keeps the filter combinations you do not want search engines to index in the part of the address after #ssf=, as described in Bot-fighting AJAX mode. The browser never sends that part of the address to the server, so bots cannot use it to crawl every combination, while shoppers can still bookmark and share exactly what they were looking at.
When Astra’s Enable Smooth Scroll to ID option is on and a page loads with anything after the #, Astra waits 750 milliseconds and then passes the whole of it, #ssf=color/black/size/m/ included, to the browser’s document.querySelector() to find an element to scroll to. A value containing = and / is not a valid CSS selector, so the browser throws a SyntaxError. Astra does not catch it, so it reaches the console as an uncaught error and Astra’s scroll stops there.
The same happens with any plugin that stores state after the # in this way. It is in Astra’s frontend.js and style.js scripts and has been confirmed in Astra 4.13.10 and 4.14.2.
Filtering is unaffected
Super Speedy Filters reads the #ssf= state with its own code, which runs separately from Astra’s scroll script, so the error has no effect on it. The products, the selected filters, the term counts and the active-filter chips all match the link, exactly as they do on a theme without the scroll feature. Visitors do not see the error unless they open the developer console.
How to confirm it is this
- Open a filtered link on your store that ends in
#ssf=...(apply two or three filters, then reload the page). - Open the browser’s developer console (F12, then the Console tab).
- Check that the error message quotes your
#ssf=value and says it is not a valid selector. - Expand the error. The stack trace points to Astra’s
frontend.min.js(orstyle.min.json older header layouts) underwp-content/themes/astra/, not to a Super Speedy Filters file. - Check that the products and the selected filters match the link.
If all of that matches, this is the Astra behaviour described here and nothing needs fixing in Super Speedy Filters. If the stack trace points to a different file, or the filters do not match the link, it is something else: post the full console message on our Discord.
Workarounds
You do not have to do anything: the error is harmless. If you want a clean console, or the error is filling up your error-monitoring service, you have two options.
Turn off Astra’s Smooth Scroll to ID
- Go to Appearance > Customize.
- Open General, then Misc.
- Switch off Enable Smooth Scroll to ID.
- Press Publish.
With the option off, Astra skips its scroll-to-ID code entirely, so the error stops. In-page anchor links such as a table of contents or a “back to top” link keep working: the browser jumps straight to the target instead of gliding to it.
To keep smooth scrolling without Astra’s script, add html { scroll-behavior: smooth; } under Appearance > Customize > Additional CSS. Browsers then scroll to in-page anchors smoothly on their own. If you have a sticky header, add scroll-padding-top with your header’s height (for example html { scroll-padding-top: 80px; }) so the target does not end up hidden behind it.
Filter it out of error monitoring
If you would rather keep Astra’s option on, tell your error-monitoring service to ignore errors whose message contains is not a valid selector and #ssf=. Only this error matches both, so genuine errors keep reaching you.
Reported to Astra
We have reported this to Astra on the wordpress.org Astra support forum, with the exact lines and a suggested fix: catching the error, or looking the target up with document.getElementById(), which accepts any value. Once Astra’s scroll code handles a value it cannot use, the error stops on its own and none of the workarounds above are needed.
Further reading
#ssf=, and how the redirects work.#ssf= links are part of.Written for Super Speedy Filters 6.75.0.
Comments