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

Plugin loading unnecessary js on frontend? #2978

Open
nikkoi opened this issue Nov 27, 2024 · 3 comments
Open

Plugin loading unnecessary js on frontend? #2978

nikkoi opened this issue Nov 27, 2024 · 3 comments

Comments

@nikkoi
Copy link

nikkoi commented Nov 27, 2024

Describe the bug

I noticed that at least as of version 3.17.0 of the plugin, it loads hooks.min.js and i18n.min.js on the front end of wordpress. I can't see why these js files would be necessary for it to run, and if they are, can you please explain how they weren't needed before.

To Reproduce

  1. Install version 3.17.0 of the plugin.
  2. See the files hooks.min.js and i18n.min.js load on the front end, when logged out.

Expected behavior

I assume this files are only needed when logged in in wp-admin

Environment

Plugin version 3.17.0
WP version 6.7.1

Additional context

Loading unnecessary JS slows the web page down.

@acicovic
Copy link
Collaborator

acicovic commented Dec 4, 2024

Hello and thank you for reporting this.

We will investigate this within this week or the next, and we'll get back to you as soon as possible.

@nikkoi
Copy link
Author

nikkoi commented Dec 4, 2024

Thank you, appreciate it! Always looking for ways to minimize js waste on the front end for speedy load times.

@acicovic
Copy link
Collaborator

Hello! Here's a summary of our findings:

General timeline

  1. The hooks.js script was introduced in wp-parsely 3.2 (released March 29, 2022) through this PR. This is a result of us including the @wordpress/hooks package as a dependency in our loader.js script, so JS hooks can be used as mentioned in the PR.
  2. In this and some subsequent versions, hooks.js needed to inject a polyfill script.
  3. When we released wp-parsely 3.11, hooks.js started injecting i18n.js instead of the polyfill.

Are these scripts needed?

loader.js is needed to disable autotracking when the "Disable Autotracking" setting is on, as well as when the website uses wp-parsely JS hooks. These are operations that take place on the front-end. hooks.js and i18n.js are loaded as dependencies of loader.js.

Considerations for the future

We could attempt to decouple the "Disable Autotracking" setting from the loader, and give a setting to disable JS hooks when they aren't being used. This would prevent the extra scripts from being included. This is a possible pathway, but it hasn't been tested.

@acicovic acicovic added this to the Future Milestone milestone Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants