In our projects, we mark scripts and CSS as resources for the class, and then register them during the page life cycle, usually in PreRender ().
For instance:
// Css [assembly: WebResource("Assembly.Class.MyClass.css", "text/css")] // Javascript [assembly: WebResource("Assembly.Class.MyClass.js", "text/javascript")] namespace OurNamespace { public class MyClass...
Then we set the properties of each of our scripts and css files as embedded resources.
This approach allows you to keep your scripts separate and target individual user interface components. You can register the same resources for several classes, and then ScriptManager will make sure that the necessary resources appear on the page.
Then we wrote a class at the HTTP handler level that handles the compression of all CSS resources into a single file before it exits the stream to make sure that we are not in the 32-bit CSS limit for IE6. It also removes spaces, comments, etc. From our scripts to optimize javascript output.
source share