To use minified JavaScrips (or CSS files) in your SharePoint 2010 solutions you can do it easy with the Microsoft Ajax Minifier 4.0 and a pre-build event in Visual Studio 2010. Just follow these simple steps when you have installed the Minifier.
"C:\Program Files (x86)\Microsoft\Microsoft Ajax Minifier 4\ajaxmin.exe" -JS $(ProjectDir)\Layouts\Wictor.Minified\TheScript.debug.js -out $(ProjectDir)\Layouts\Wictor.Minified\TheScript.js -CLOBBER
Then add a Visual Web Part to your project and add code as follows:
<SharePoint:ScriptLink runat="server" Name="Wictor.Minified/TheScript.js" Localizable="false"/> <asp:Button runat="server" Text="Click me!" OnClientClick="thisIsMyFunction('Hello mini!');" />
Make sure that your SharePoint web application does not have debugging configured in the web.config and hit Ctrl-F5. This will start Internet Explorer and you can add the Web Part to a page. Then take a look at the source and look for your script. It should look something like this.
Then hit F5 to run the project in debug mode and inspect the source of the page. You can now see that the debug version is loaded.
That's it! Simple! Now go on minifying!