Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Suggestion: only load js and css when S&F is in use

Viewing 2 posts - 1 through 2 (of 2 total)
  • webteam webteam
    #213533

    We’ve been using Search & Filter Pro and noticed it always loads Javascript and CSS files even when Search & Filter is *not* used. This has a negative impact on the performance due to needlessly loading an extra (roughly) 110KB of data (although this will be cached after the initial load).

    In your FAQ you mention a possible solution which is not adhering to best practices used in WordPress Core nor plugins in the larger WordPress ecosystem.

    Your current implementation always loads the files even when not needed. Please consider refactoring your code and make your js & css files load conditionally (thus *only* add 110KB of data when needed).

    If you are open to this suggestion we are willing to help with this and provide patches to realize this change, please let us know.

    Kind regards,
    Björn Wijers

    Ross Moderator
    #213536

    Hi Bjorn

    S&F already has this option – check settings -> lazy load Javascript

    This means, JS will not be loaded until a search form is present on the page somewhere.

    However, with CSS, this is not strictly possible.

    CSS should be loaded in the head of a page, however, sometimes we do not know if a page contains a search form, until some of the body (ie, on of our shortcodes) has already been printed… which means its not possible (whilst keeping to standards) to conditionally load our CSS, unless we want to print it inline.

    My recommendation is to enable lazy load Javascript, and then conditionally unload our CSS, based certain rules so you know it only shows it on the page with the search form on.

    As far as I’m aware, this is not considered bad practice – if you can share any better methods / logic of approaching this I’d be happy to hear 🙂

    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.