parisholley / wordpress-asynchronous-javascript

Improve page load performance by asynchronously loading javascript and files using head.js in your wordpress website.
http://wordpress.org/extend/plugins/asynchronous-javascript/
24 stars 3 forks source link

Wrap in-line jQuery calls on page to support head.js #1

Open parisholley opened 11 years ago

parisholley commented 11 years ago

Idea I have in my head is to find all script blocks that contain jQuery, and wrap it with with head.ready('jquery', function(){ ... }); This would allow plugin to work in admin as well any plugins that write inline javascript.

paulthomson-me commented 11 years ago

If my memory serves me correct, http://wordpress.org/extend/plugins/headjs-loader has that functionality built in... might be a good starting point...

Thanks again for such an excellent plugin,

Paul

parisholley commented 11 years ago

looks like it was added recently :)

it is a good generic way of doing it (which i may add) but it waits for all scripts to load which adds some delay instead of waiting on the single dependency you really need. one of the reasons I went with my implementation is to be able to register javascript includes by their keys, so you can do head.ready("jquery"), otherwise you will have to do head.ready("http://...") [viewing the head.js, it doesn't support partial url name, like "jquery.js"] which is problematic because you may have scripts that are shared across http/https, or if you have non-inline calls, you have to hardcode url locations/versions.