AhmadHamdan Posted September 23, 2015 Share Posted September 23, 2015 Hello all, The error is occurring on the product page so let me explain what the default behavior of the page is before proceeding. You can find an example here https://sportstown.me/shoes/7400-nike-capri-3-leather-gs.html I tweaked the original code a bit to include a Google Map down at the bottom. The purpose of this map is to eventually show the users where the product combination they selected is available in the country. That's pretty much it. I only recently enabled caching for my e-commerce website via the back-end (Advanced Parameters -> Performance) but then I noticed an unwanted behavior on the product page. The moment I enable caching and visit the link I posted earlier, nothing wrong happens, however if I refresh the page I notice that I get a JS error telling me a certain function is undefined. That function that I created is however defined in a file called "stores.js" located under "themes/my_theme/js/stores.js" yet for some reason the caching omits this file all-together. Can anyone pinpoint what the problem is or might be? As a short-term solution I disabled caching via the back-end but I don't want to keep it that way for the sake of optimizing my website's performance. I am using Prestashop 1.6.0.9. Thanks in advance. Link to comment Share on other sites More sharing options...
NemoPS Posted September 23, 2015 Share Posted September 23, 2015 Does your js have any comment with // ? If so, that's what breaks it as the code gets minified Link to comment Share on other sites More sharing options...
AhmadHamdan Posted September 23, 2015 Author Share Posted September 23, 2015 Hello Nemo1, Thanks for the quick reply. Yes there were a few //comments but I amended them all, emptied the smarty cache folders, re-enabled cache and re-tested the page but unfortunately the error persists. I'll appreciate any further help Link to comment Share on other sites More sharing options...
NemoPS Posted September 25, 2015 Share Posted September 25, 2015 The only suggestion I can give you is going through your code using developer tools in the browser, and see where it changes color to the comments one, as it's likely the issue you're having Link to comment Share on other sites More sharing options...
AhmadHamdan Posted October 15, 2015 Author Share Posted October 15, 2015 (edited) Hello Nemo1, So sorry for the late reply, but I was pre-occupied with other stuff. I took your advice and I went to "Advanced Parameters" -> "Performance" and disabled "Smart cache for JavaScript", and that seemed to do the trick, therefore it is definitely the case of bad commenting like you said. I will mark your answer as solved. Thanks for the help! Edited October 16, 2015 by AhmadHamdan (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted October 16, 2015 Share Posted October 16, 2015 No, it is not, it's exactly as I said. Smart cache compresses javascript. It means comments like // will comment out everything coming after, breaking it Link to comment Share on other sites More sharing options...
AhmadHamdan Posted October 16, 2015 Author Share Posted October 16, 2015 Nemo1 I agree, I had a typo in my last reply, all fixed now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now