I found a library called Xpedite. the URL of the project is http://xpedite.codeplex.com. From here anyone can download the project with a sample. I checked this library and it is good.
The user only needs to wrap up the js file name with page like this:
<xpedite:CompositeResourcePlaceholder runat="server" />
<xpedite:CompositeResource runat="server" Type="Css" ReferenceName="jquery-ui">
<xpedite:Resource Url="/Styles/Site.css" />
<xpedite:Resource Url="/Styles/jquery.ui.accordion.css" />
<xpedite:Resource Url="/Styles/jquery.ui.all.css" />
</xpedite:CompositeResource>
<xpedite:CompositeResource runat="server" Type="JavaScript" ReferenceName="jquery-ui">
<xpedite:Resource Url="/Scripts/jquery-1.4.2.js" />
<xpedite:Resource Url="/Scripts/jquery.ui.core.js" />
<xpedite:Resource Url="/Scripts/jquery.ui.tabs.js" />
</xpedite:CompositeResource>
Everything is working fine but I always have to define JS & CSS file in .aspx page level. Maybe sometimes I would like to add my JS & CSS from code-behind. I found no way to do it,
so if anyone know it then please share the knowledge with me or download the project and check…I checked it but found nothing.
I am not an advanced developer but I need to wrap up the JS file in CompositeResource from code behind.
You might give the RequestReduce library a try. This library offers the same functionality as Xpedite and will minify and combine your css and javascript files. It can also sprite your css background images. With RequestReduce, it does not matter if your resources are defined on the aspx or the codebehind. Either way, as long as html that is streamed to the browser contains link and script tags with the javascript and css files, RequestReduce will process them.