Curl: Preload jquery plugins

47 views
Skip to first unread message

Евгений Куртов

unread,
Apr 20, 2013, 6:38:53 AM4/20/13
to cuj...@googlegroups.com
Hello!  I create a html widget with  autocomplete and  datepicker, which both are jQuery plugins. So I need to noConflict load jQuery from Google CDN, and after that load & initialize these two plugins. 
Basic requirments are:
1) hit network as minimum as possible: load jquery plugins and main code in one script but keep them in separate files in development. 
2) avoid conflicts with existing jquery on the 3rd party site (keep it for 'private' use only :). 
Is this something I want to use curljs for? 

unscriptable

unread,
Apr 22, 2013, 11:06:08 PM4/22/13
to cuj...@googlegroups.com
Hi!

How many files/modules are there in total?  If there are just a few, then you may want to use the jquery UI site to concatenate the plugins into a single file (using their custom download tool: http://jqueryui.com/download/), prepend jquery into this file, and then append a line to call noConflict: `jQuery.noConflict();`.  It's pretty easy to write an async script injector that will load this concatenated file.  Here's an example:  https://github.com/know-cujojs/monty-hall/blob/master/client/test/ui/launch.html#L83-L89

If you have many modules, then curl.js/cram.js might be better suited to the task.

Regards,

-- John
Reply all
Reply to author
Forward
0 new messages