Including a JS file for a custom ribbon control CommandUIHandler without using a ScriptLink CustomAction or Custom Page Components
I've been struggling lately with the proposed solutions for including the javascript for CommandUIHandler's CommandAction and EnabledScript attributes. Thus far I have only seen the following examples: JavaScript directly into the attributes (messy), Including a ScriptLink command action (bad because then the script file is included in every page where the feature is activated causing bloated pages) Creating a page component (overcomplicated) Instead of all this, I created a pattern which loads the js file on the fly with javascript and keeps your ribbon development more compact (note I have JQuery loaded in the master page, if you don't have this then you'll have to either load jquery dynamically or reference the elements without JQuery): <commanduihandler CommandAction="javascript: ...