Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some way to intercept and modify the html output stream in asp.net, to combine the javascript?

Is there some way to intercept the HTML output stream in asp.net and make modifications? Eg using httpmodules or something? I know this is possible using java servlets and assume there must be an elegant way to do this with asp.net.

My purpose is to combine the many javascript files into one composite script which has been minified/packed, to make the page load faster.

Eg, if my page normally outputs the following in the page head:

<script type="text/javascript" src="/scripts/blah.js"></script> 
<script type="text/javascript" src="/scripts/yada.js"></script> 

I want to replace that with the following:

<script type="text/javascript" src="/scripts/all.js"></script> 

(also i realise i'll have to create all.js somehow). Thanks!

like image 659
Chris Avatar asked Oct 25 '22 23:10

Chris


1 Answers

You can set Response.Filter.

like image 189
SLaks Avatar answered Dec 04 '22 09:12

SLaks