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?

Developer technologies | ASP.NET | Other
Developer technologies | C#
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 30,191 Reputation points Microsoft External Staff
    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.