Help with js triggered by “do_shortcode” in php
-
I’ve managed to tune Autoptimize to do just about everything I think I need right now (Pagespeed scores of 95+!), except one pesky thing: I use a charting plugin called M-Chart to create about 150 charts that need to be placed within dozens of pages in my site.
To do the placement, I use the “do_shortcode” statement in php, and fill in the chart id number from my database. The charting plugin relies on jQuery, but as you maybe can guess, with scripts deferred by Autoptimize, the php code tries to call jQuery before it’s loaded, and I get a “jQuery is not defined” console error at several spots in my page.
I definitely prefer to have jQuery deferred, because it’s otherwise render-blocking and a pain in the you-know-what. And when I don’t use Autoptimize to defer jQuery, it and a bunch of my other scripts need to be excluded to work properly.
So my question is: Is there a way to have my cake and eat it to, by triggering the “do_shortcode” statements only after the rest of the js is loaded? The rest of the page(s) in question are populated by database calls through php, so I can’t just rewrite the page templates and put the shortcodes into the normal WP editor.
The page I need help with: [log in to see the link]
- The topic ‘Help with js triggered by “do_shortcode” in php’ is closed to new replies.