• Resolved George

    (@giorgos93)


    Hi, Hector!

    I use optimization plugin on my website (Asset Cleanup Pro). And it has an option to combine loaded javaScript into fewer files. I enabled it a long time ago, and noticed that the only problem that appears, is with your plugin. So I had to add it in exceptions.

    Several months later I decided to remove it from exceptions and recheck. The problem is still there. So I want to show it:

    After turning on js combining, in Google Dev console appears an error: Uncaught SyntaxError: Unexpected token ‘:’ (/wordpress-popular-posts/assets/js/wpp.min.js file). And popular posts design in sidebar gets broken.

    Also, I have a plugin WP Front Notification bar. I added a fixed bar with text and button at the bottom of my website. For some reason, if I remove your js file from combining exception, then this bar disappers. Even though it’s files are not added in any exceptions.

    Here are screenshots:

    1 – https://ibb.co/LppF6PZ

    2 – https://ibb.co/9sQ7bcX

    3 – https://ibb.co/5k9x3M9

    4 – https://ibb.co/4RW3hGc

    Now I returned your file back to exceptions. I hope, you can solve this, so I don’t need to add your file in exceptions anymore!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @giorgos93,

    I hope, you can solve this, so I don’t need to add your file in exceptions anymore!

    I would but I can’t as this issue isn’t being caused by WordPress Popular Posts. See: Is WordPress Popular Posts compatible with plugins that minify/bundle JavaScript code?

    Thread Starter George

    (@giorgos93)

    Oh, so it’s on their side. I see.

    Okay, I’ve just read the instruction. If I add /wp-content/plugins/wordpress-popular-posts/assets/js/wpp.min.js in exceptions, and everything works okay, then I don’t need to add a whole /wordpress-popular-posts/assets/js/ path in exceptions, right?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Oh, so it’s on their side. I see.

    Correct. If you take a closer look at your second screenshot you’ll notice that Asset Cleanup Pro is trying to execute a JSON string as if it was a regular JavaScript code. Hence the Unexpected token ':' error message you’re seeing.

    Ideally, Asset Cleanup Pro (and other plugins like it) should not attempt to minify / bundle inline script code, only actual .js files. Or at least check that the inline script is not a type="application/json" one (like WPP’s) before attempting to bundle its contents into a minified JS file.

    If I add /wp-content/plugins/wordpress-popular-posts/assets/js/wpp.min.js in exceptions, and everything works okay, then I don’t need to add a whole /wordpress-popular-posts/assets/js/ path in exceptions, right?

    Yep, correct.

    Thread Starter George

    (@giorgos93)

    Thanks for advices! It actually does have the option to minify SCRIPT tags with “src” attribute (default) / SCRIPT tags with inline JS code / All SCRIPT tags * both options. I am not a programmer, so I just always turn on the more attractive option (in my opinion), and see what happens 🙂 Do you think, I should turn on minify SCRIPT tags with “src” attribute (default) option then?

    And since I’ve asked you: can you please give an advice about the same options for css files? Should I turn on minify LINK tags with “href” attribute (default) instead of STYLE tags with inline CSS code and All LINK & STYLE tags * both options too?

    Thanks in advance!

    Plugin Author Hector Cabrera

    (@hcabrera)

    Do you think, I should turn on minify SCRIPT tags with “src” attribute (default) option then?

    Yeah, I think that that sounds like a safe option to use (hence why the developers of the plugin set it as “default” as there’s a good chance that it won’t break anything). Try it out and see what happens.

    And since I’ve asked you: can you please give an advice about the same options for css files? Should I turn on minify LINK tags with “href” attribute (default) instead of STYLE tags with inline CSS code and All LINK & STYLE tags * both options too?

    If you’re using any of the WPP themes (Cards, Cards Compact, etc) then you’ll want to pick the first option and leave inline <style> tags alone, else the design of your popular posts list -again, if you’re using any of the built-in widget themes- will break. If you’re not using any of the built-in themes then yeah minifying inline <style> tags should be fine (or at least that won’t cause issues with WPP).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Uncaught SyntaxError: Unexpected token ‘:’’ is closed to new replies.