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

When activated, surveyjs plugin loads many js files from /wp-includes/js/dist/ #17

Open
msbt opened this issue Apr 5, 2020 · 9 comments
Labels
question Further information is requested

Comments

@msbt
Copy link

msbt commented Apr 5, 2020

I was wondering why there were so many js files being parsed on my WP site and figured, that if the surveyjs plugin gets activated, all the included js files in the WP dist directory are being loaded. Usually only enqueued scripts should be added, but as soon as surveyjs is activated, all (!) of them are included.

I did a bit of digging and found this post where the last post identifies register_block_type as the culprit. I did a quick search and found that the correct editor_script is used. Any idea what else might cause that?

Best regards,
Matthias

@tsv2013 tsv2013 added the question Further information is requested label Apr 6, 2020
@tsv2013
Copy link
Member

tsv2013 commented Apr 6, 2020

First of all - how we can reproduce it? And what scripts do you expect to be loaded?

@msbt
Copy link
Author

msbt commented Apr 6, 2020

To reproduce, just fire up a (fresh) Wordpress installation, compare the scripts that were loaded before and after activating surveyjs.

Before (9 queries, 159,16 KB):
grafik

After (54 queries, 3,08 MB):
grafik
...

As for the scripts that I expect to be loaded: This is not a page where surveyjs is activated, so technically none. If there would be a survey on a page, only the ones that came with surveyjs should be loaded, since all required ones are included there. None of the WordPress dist files are required I reckon.

@tsv2013
Copy link
Member

tsv2013 commented Apr 6, 2020

Looking at this long list I see the only SurveyJS script - "survey.jquery.min.js". Other scripts are neither related by SurveyJS library (excluding jQuery script) nor mentioned in SurveyJS wordpress plugin code. Most likely this question is not related to SurveyJS and should be asked in Wordpress community.

@msbt
Copy link
Author

msbt commented Apr 6, 2020

that's what I meant, something in the surveyjs plugin loads all those scripts even though they're not needed, that shouldn't happen.

@msbt
Copy link
Author

msbt commented Apr 6, 2020

there are a few plugins with the same issue, maybe the gutenberg implementation is to blame?

https://wordpress.org/support/topic/plugin-loads-a-lot-of-js-files-in-frontend/
https://wordpress.org/support/topic/loading-all-js-in-wp-includes-js-dist/

@tsv2013
Copy link
Member

tsv2013 commented Apr 6, 2020

I'd like to say that the loaded scripts are not mentioned in the plugin code.

I've checked these issue and both of them have no answers.

In case of any wordpress option control this bloating scripts loading exists we'll definitely use it in our plugin code.

@msbt
Copy link
Author

msbt commented Apr 6, 2020

@tsv2013
Copy link
Member

tsv2013 commented Apr 6, 2020

If you are using the source code of SurveyJS Plugin in your Wordpress instance, could you try these approoaches on your side?

@msbt
Copy link
Author

msbt commented Apr 6, 2020

I'm not that kind of developer, but I'll give it a try and keep you posted.

I already can tell you that if I remove the gutenberg functionality (since I'm not using the gutenberg editor) with commenting the register_sjs_gutenberg_block function, is shows only the js files needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants