ICS Calendar version 10.6 introduced a new feature that changed how and when the plugin’s JavaScript and CSS files get loaded, deferring loading to the end of the page (including the CSS), and only loading them on pages that actually include a calendar.
It’s a good goal! Not loading extra assets on pages that don’t use them is better for site performance, SEO and PageSpeed analytics. Unfortunately, as I learned through a couple of weeks of troubleshooting, it can also introduce a wide range of seemingly unrelated issues, especially with regard to:
- Optimization plugins that consolidate JS and CSS files
- Custom CSS (both in the Customizer and in themes)
- The FullCalendar library
The last item, which only affects Pro users who are using the new Full view, is perhaps the most confounding, because Full view loads, and its CSS gets applied, but certain parts of its CSS are not working properly, specifically the block height for events in the week and day time grid views.
I found this deferred loading was also causing the Pro version’s Customizer settings not to get applied. And on top of this, numerous users were contacting me about problems they were having with their CSS customizations getting lost, or their optimization plugins causing the calendar or sometimes the entire page the calendar is on not to load.
After spending the better part of two days trying several different approaches to salvaging this conditional/deferred loading, I am — temporarily — acknowledging defeat, and restoring the old functionality that enqueues ICS Calendar’s JS and CSS files in the standard way.
The “standard way” has two problems for modern, highly optimized web pages: 1) it includes some render-blocking CSS, and 2) it loads JS and CSS assets on pages where they’re not needed. But! It’s the way WordPress is basically designed to work.
The problem was compounded in my testing by the fact that some of these things work differently in Block Themes than in classic themes. Getting certain things to work in one type of theme has been breaking them in the other, and I haven’t been as comprehensive in my testing as I apparently need to be.
So, for now, ICS Calendar 10.7.1.1 and Pro 4.4.3.1 revert to the pre-10.6 functionality, while I look for a more reliable permanent solution to the conditional loading conundrum.
—Scott