I have an empty template with just a safecracker form consists of 2 custom field. When i try to load it up in the browser, it takes about 2-3 seconds to load. Looking in firebug i see the following GET
http://localhost/ee1/?ACT=7&ui=core,widget,mouse,position,draggable,resizable,button,dialog,datepicker&plugin=scrollable,scrollable.navigator,ee_filebrowser,ee_fileuploader,markitup,thickbox,toolbox.expose,overlay,tmpl&v=1308711156&use_live_url=y&include_jquery=y
I don't need to load most of the things showing in the url above. How can i control what is loaded with safecracker form. I will be loading jQuery/UI directly from google so i don't need safecracker to load it. I'm able to remove jQuery and datepicker from safecracker form by doing datepicker="no" include_jquery="no"
, but what about removing other things mentioned in the url such as scrollable, draggable, thickbox and other things.
Sadly, there's no way to disable many of the included SafeCracker JavaScripts.
SafeCracker is designed to be as general purpose as possible and to suit the needs of the largest audience.
With this tradeoff, SafeCracker bundles jQuery, jQuery UI Widgets, jQuery Tools and various other jQuery Plugins and functions to facilitate client-side form validation and presentation of custom fieldtypes.
As you've shown, you can disable jQuery from automatically being output by SafeCracker — say, if you want to use a newer version that what's available from EE's Control Panel — and can you disable the DatePicker, but as far as I know you can't prevent the rest of the JavaScripts from being output without hacking the core SafeCracker library.
Understandbly, I'm not a big fan of this "include everything and the kitchen sink approach" and hate seeing extraneous and bloated scripts being added to the page — especially ones that I would never use in the first place.
Nevertheless, it's clearly a design decision that SafeCracker was built to include all of the JavaScripts it outputs since there isn't an approved way to remove them. So we're essentially stuck dealing with them for the unforeseen future.
If you feel strongly about this, I would suggest submitting a Feature Request to EllisLab to allow more configurability to SafeCracker's sloppy way of outputting more JavaScripts that what's really necessary.
For the curious, take a peak around Line 887 in the following file to see just how many jQuery UI Widgets are bundled in the SafeCracker tag pair.
/system/expressionengine/modules/safecracker/libraries/safecracker_lib.php
Note: If you want to take matters into your own hands, you can comment out some of the items in the $js_defaults
and $ui
array, which will remove the JavaScripts from being output. However, in doing so you assume all responsibility and risk for SafeCracker's operation.