


This makes sure that the jquery-ready.js script will be executed only after the jQuery was executed. any other plugins for jQuery you probably need Create a new JS script jquery-ready.js with next content: // When jQuery is finaly ready The function jQueryReady will just save delegates into an array for future use.Ģ.
WP ENQUEUE SCRIPT DEFER JQUERY CODE
I'd like to defer loading of jQuery this way, but when I tried it my jQuery code failed to find jQuery (not completely unexpected on my part): $(document).ready(function() Window.attachEvent("onload", downloadJSAtOnload) Window.addEventListener("load", downloadJSAtOnload, false) Check for browser support of event handling capability Var element = document.createElement("script") There are already many questions similar to this one, but all answers I've found so far boil down to call wpenqueuescript inside the wpenqueuescripts action hook, which I'm already doing. It seems that my wpenqueuescript calls are simply ignored. Add a script element as a child of the body I'm having a tough time including jquery-ui scripts and styles in my plugin. It works in tandem with a very similarly named bit of code, wpenqueuescripts, which is the WordPress action hook to which our individual calls to wpenqueuescript () will stick. Google's deferral code adds a tag to the DOM after the page loads by hooking into the body onLoad event: In short, wpenqueuescript () is the function that tells WordPress to add onenqueuea new JavaScript file for addition into WordPress. My page uses jQuery to set up some tabs which are placed low on the page (mostly out of initial view) and I'd like to defer jQuery until AFTER the page has rendered. Google recommends deferred loading of JavaScript to speed up initial rendering. Let's face it, jQuery/jQuery-ui is a heavy download. The review of script and styleloadertag by Remzi Cavdar is interesting, but, at the risk of provoking some outrage, and in the hope that someone can remind me what the advantage of using the WP queue would be in cases like this one, I'll recommend taking the easy way out, and loading Fontawesome's stylesheet via hook.
