From time to time we run into issues with the calendar and page builders where the calendar scripts aren't loading on the page.
We usually provide a snippet that loads the scripts on specific pages, but then that means they need to update that snippet if they add additional pages. If we load the calendar scripts on all pages to work around that then you'll get a JS error on any page that doesn't use the calendar shortcode:
espresso_calendar.js?ver=3.2.12.p:55 Uncaught ReferenceError: eeCAL is not defined
at HTMLDocument.<anonymous> (espresso_calendar.js?ver=3.2.12.p:55)
at i (jquery.js?ver=1.12.4:2)
at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
at Function.ready (jquery.js?ver=1.12.4:2)
at HTMLDocument.K (jquery.js?ver=1.12.4:2)
## Bug report or feature request?
Issue Overview
From time to time we run into issues with the calendar and page builders where the calendar scripts aren't loading on the page.
We usually provide a snippet that loads the scripts on specific pages, but then that means they need to update that snippet if they add additional pages. If we load the calendar scripts on all pages to work around that then you'll get a JS error on any page that doesn't use the calendar shortcode:
http://take.ms/IUVzg
Steps to Reproduce (for bugs)
Add this snippet to your site: https://gist.github.com/joshfeck/5d9c88fea504c0b111c3df8f24ad25d9
Remove the
&& is_page( 'calendar' )
from line 7 and visit any page that doesn't use the calendar shortcode.The fix for the above is to add a check for eeCAL in espresso_calendar.js, whilst not ideal it prevents the error and doesn't cause any other issues.