Uncaught SyntaxError: Unexpected token ‘)’
-
Hey Raul,
All of a sudden all our websites using your plugin have an the following error message in the cached footer js:
Uncaught SyntaxError: Unexpected token ‘)’
Clearing cache temporarily fixes it but it will return as soon as a new footer file is generated.
Any idea what is causing it?
Thanks in advance,
ThomasThe page I need help with: [log in to see the link]
-
The error triggered on that line is due to double minification on https://thomasvanderburg.com/wp-content/themes/Divi/includes/builder/frontend-builder/build/frontend-builder-scripts.js
Disable any minification on your theme.
Divi must have updated something and the double minification is causing the error.You can also disable minification of js files on FVM for testing.
Unfortunately, we use PHP Minify for compressing (same as wp rocket, w3tc and others) and sometimes that library causes issues with minification.I’ve been considering making my own library just for javascript, but no time yet.
Hey man,
Weird..I don’t see anything that could cause double minification. Divi did not add anything new or something.
Also disabling minification of js files does not fix it. Could it be something else?
Thanks for the response!
EDIT: Hey man, it has something to do with version 2.8.2 or 2.8.3 of FVM. I just updated FVM on a site that didnt had the error (running 2.8.1) and as soon as i updated the error started happening.
- This reply was modified 4 years, 7 months ago by zuoothomas.
I disabled js min on my divi site and it’s working again.
Weird..I don’t see anything that could cause double minification. Divi did not add anything new or something.
The file
https://thomasvanderburg.com/wp-content/themes/Divi/includes/builder/frontend-builder/build/frontend-builder-scripts.js
is minified by default by Divi. FVM doesn’t know it’s already minified, because that url doesn’t end in .min.js so naturally, it minifies it again.That’s what I mean by double minification.
Solution right now, is to disable JS minification on FVM until I have an update where that file will be automatically excluded from being minified again.
And you need to purge caches after that.
- This reply was modified 4 years, 7 months ago by Raul P..
I added frontend-builder-scripts.js to the list of exclusions so FVM will be able to merge it without minification.
Remember to purge all caches after the update, both FVM and whatever server / cache plugin / cloudflare you may be using.
Thanks for pushing out the new update, it sounds like that would’ve fixed it.
But for some reason the error just doesn’t want to go away. I cleared all possible cache there is, leave the status tab of FVM open on one screen (with no processed js files). Then i open the website on an incognito browser, and see a newly created footer.min.js file created. The filename (including all hash code) matches the file giving the error.
Turning off javascript minification does not get rid of the error. “Disable javascript processing” does get rid of the error, same with disabling the plugin.
Opening the log of the footer.min.js i still see /wp-content/themes/Divi/includes/builder/frontend-builder/build/frontend-builder-scripts.js on the list of processed items.
if I put that file on the ignore list it also fixes the error but then it obviously is not merged.
Sorry for taking so much of your time, I really don’t want to switch to an alternative as FVM has been the best experience so far!
Thanks in advance,
ThomasThe thing is, I still have a website running an old version of FVM. I’m not having the error on that website. So I have no idea what happened in between updates of FVM that is causing the error. On that old version of FVM it merges and minifies frontend-builder-scripts.js without any problems, while running the same version of Divi (and every other plugin).
So it must be something from one of the updates of FVM that changes the way it behaves around frontend-builder-scripts.js.
I know they are still assumptions but to me personally, that sounds logical to me.
The issue is certainly to do with the minification done by PHP Minify and the latest update was supposed to skip minification for that file.
If disabling minification fixes it, you have confirmation that it’s a minification issue, which is basically PHP Minify action on top of merging it.
PHP Minify was updated by FVM on version 2.7.8.
Which older version are you using that works?And more importantly, does bringing that old plugin version to the new site where you having trouble works?
From what I’ve been seeing, Divi done some updates recently and even simply merging CSS got broken (no minification). So it’s not only about FVM version but also about which set of plugins and exact theme version you are using.
Please test that older FVM version on the site where you are having trouble and let me know if it works on that site.
You can get older versions by replacing the version number on the url:
https://downloads.www.ads-software.com/plugin/fast-velocity-minify.2.8.4.zipVersions available are here:
https://www.ads-software.com/plugins/fast-velocity-minify/#developersHey,
Thanks for the quick reply.
If disabling minification fixes it, you have confirmation that it’s a minification issue, which is basically PHP Minify action on top of merging it.
Disabling minification did not fix it for me, only completely disabling merging or putting the file on the ignore list fixed it for me.
Thanks for the tip of downloading older versions. I tested a few version multiple times and it seems like version 2.8.3 is when the error started happening. On 2.8.2 i do not get the error.
BTW, i see on the changelog of 2.8.4:
added frontend-builder-global-functions.js to the list of minification exclusions, but allowing merging
but it is not frontend-builder-global-functions.js that is causing it but frontend-builder-scripts.js
Thanks for the tip of downloading older versions. I tested a few version multiple times and it seems like version 2.8.3 is when the error started happening. On 2.8.2 i do not get the error.
but it is not frontend-builder-global-functions.js that is causing it but frontend-builder-scripts.js
Thank you very much, this is helpful.
I’ll review that update and get hopefully get it sorted today.Can you please try 2.8.5 and check if it works for you?
I have Divi installed on a few sites but couldn’t reproduce the issue.
It could be server specific, so I am not sure.Also if you have some issue video related, try to add
/wp-includes/js/mediaelement/wp-mediaelement.min.js
to the ignore list as well.Hey Raul,
Sadly the new update (2.8.6) did not fix it. Again, only when putting frontend-builder-scripts.js on the ignore list the error goes away.
Strange that you can’t reproduce the error on your side. I just installed FVM on a fresh Divi site and again version 2.8.2 did not give any error but starting from 2.8.3 the error occurs.
This makes me think how this could be a server side issue. If you need anymore information, let me know!
Btw, I also noticed “/wp-content/themes/Divi/core/admin/js/react-dom.production.min.js” is not on the ignore list anymore, any reason why?
The differences between 2.8.3 and 2.8.4 are very very minimal.
The only case that could impact the situation, is a new regex that I added to remove source maps from javascript.I cannot reproduce it because your site must be using different modules or different versions of plugins and theme.
Disabling minification did not fix it for me, only completely disabling merging or putting the file on the ignore list fixed it for me.
In that case, the update wouldn’t do anything about it.
I assumed that the error was simply the PHP Minify stripping some code from the regex function, as reported here: https://github.com/matthiasmullie/minify/issues/329But it appears I was wrong and it’s instead something else.
It could be that new regex I added as I don’t think it could be anything else.I added the unicode flag on 2.8.6 assuming you could be having mixed encodings on that file, but that doesn’t seem to be the reason.
If you would like to check if it’s related to that, you can find it on the plugin directory, under
fast-velocity-minify/inc/functions.php
on line 329.If you can comment that line out (prefix a # before it) and test it again, and if it works, let me know.
But the regex should be fine, so I would need to see the exact error and later debug the file differences, with and without that regex.
If not, I am sorry but you will need to use the ignore list.
As I said, I have Divi on several sites, some old some new, and they are running FVM without having that error on that file.
It may be some module you use so I don’t have that for testing.
Those js files are unique to your site.This makes me think how this could be a server side issue.
It could be, because regex acts sometimes differently in different servers, OS or PHP versions dependng on where you are running it.
https://stackoverflow.com/questions/1377030/php-regex-behaves-differently-on-different-versions-or-different-ossSo yes, the new regex I added could be fine on my end and not on yours.
And yes, maybe the regex is removing something on your file that shouldn’t, but then that would be an edge case that I need to see.- This reply was modified 4 years, 7 months ago by Raul P..
The differences between 2.8.3 and 2.8.4 are very very minimal.
Do you mean between 2.8.2 and 2.8.3? That is where the issue started.
Thanks for all the other information. I’ll check it out for a second and if I can’t figure out anything unusual we’ll just use the ignore list.
Thanks for all the help!
- The topic ‘Uncaught SyntaxError: Unexpected token ‘)’’ is closed to new replies.