How to serve minified WebForms.js and WebUIValidation.js?

Triangulumlightstar 96 Reputation points
2021-11-22T14:19:42.327+00:00

I set debug="false" in web.config. And ScriptMode="Release" in ScriptManager on page.

But the following are still served unminified:

<script src="https://ajax.aspnetcdn.com/ajax/4.6/1/WebForms.js" type="text/javascript"></script>
<script src="https://ajax.aspnetcdn.com/ajax/4.6/1/WebUIValidation.js" type="text/javascript"></script>

Here's my ScriptManager on page:

<asp:ScriptManager runat="server" CompositeScript-ScriptMode="Release" EnableCdn="true" LoadScriptsBeforeUI="false"></asp:ScriptManager>

Please, without using the bundling process, how can I serve minified WebForms.js and WebUIValidation.js versions from aspnetcdn?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,285 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,299 questions
0 comments No comments
{count} votes

Accepted answer
  1. Triangulumlightstar 96 Reputation points
    2021-11-24T09:56:42.607+00:00

    It seems that aspnet CDN doesn't serve minified versions of WebForms.js and WebUIValidation.js. So I found a shorter way than the legacy Bundling and Minifying which works for me & thought to share in case any one will find it useful.

    The quick solution for me lies in minifying them myself, placing them locally, then calling them as follows:

    <asp:ScriptManager runat="server" CompositeScript-ScriptMode="Release" EnableCdn="true" LoadScriptsBeforeUI="false">
            <Scripts>
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms_4.6.min.js"/>
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation_4.6.min.js"/>
            </Scripts>
    </asp:ScriptManager>
    

    This will replace just these 2 with a minified local version while the other ScriptManager or Ajax scripts will be intact.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Lan Huang-MSFT 25,871 Reputation points Microsoft Vendor
    2021-11-23T03:06:55.66+00:00

    Hi @Triangulumlightstar ,
    debug="false" enables bundling and minification at the same time.
    If you use CDN, you need to replace the local jQuery package with the CDN jQuery package.
    You can refer to Bundling and Minification.
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Triangulumlightstar 96 Reputation points
    2021-11-23T10:07:16.067+00:00

    Hi, sorry but I need to serve them from the CDN.

    I guess with the Bundling and Minification you mentioned, they won't be served from aspnetcdn.