Guide for packaging the JavaScript loaded by the script manager from a CDN in Asp.Net

Currently, I am working on an asp.net application that utilizes a script manager in the master page. My goal is to load all scripts related to the script manager from a CDN, so I have set EnableCDN="true" in the script manager.

<asp:ScriptManager runat="server" EnableCdn="true" />

However, I have observed that each script is loaded separately, leading to an increase in HTTP requests. Is there a way to bundle all these scripts into one single file?

Has anyone managed to achieve this bundling of CDN-loaded scripts into a single JS file in asp.net (not MVC)?

Here is a snapshot of all JS files currently being loaded individually: https://i.sstatic.net/yzAJq.png

Answer №1

Only application-relative URLs (~/url) are permitted in the ScriptBundle. CDNs can only be used at the top bundle level.

One option is to compile the entire bundle yourself and upload it to a CDN like this:

https://ajax.aspnetcdn.com/ajax/4.6/1/MsAjaxJs.js
.

bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs", "https://ajax.aspnetcdn.com/ajax/4.6/1/MsAjaxJs.js").Include(
    "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));

Additionally, optimizations are activated when compilation is set to false in the web.config file.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Practical steps for programmatically adding or removing md-disable-backdrop in md-sidenav

Can the md-disable-backdrop attribute be removed from HTML? The issue arises when opening the side navigation as the md-sidenav does not have the md-disable-backdrop attribute. After making a selection from the form displayed in the side navigation, I now ...

The server nodejs is unable to recognize the dotenv file

This is my very first project with the MERN stack and I'm currently working on pushing it to GitHub. Since I am using Mongoose, I needed to protect the login credentials for my account. After some research, I discovered the solution of using a .env fi ...

Restart the calling process using NodeJS command

Is there a way to automatically restart the calling process in case certain events occur while querying a database? I want the process to start over if specific conditions are met. ...

How to style a div for printing using CSS

Currently, I am working on a project that has already been completed but now requires some enhancements. To give you an overview, the project includes a search functionality that displays additional details upon clicking on the displayed name in the result ...

Guide on displaying a stationary image using flask and JavaScript

Embedding an image in the HTML code is pretty straightforward: <img src="{{url_for('static', filename='#UserData/user/profile/profile_pic.jpg')}} " width='200' height='200' /> It works flawlessly wit ...

Custom Tooltips arrow is not receiving the CSS styling

I have implemented ReactTooltip from the ReactTooltip library You can view an example here Component Setup <ReactTooltip className={styles.customTheme} id={id} place={placement} effect="solid"> {children} </ReactTooltip> Stylin ...

Get a webpage that generates a POST parameter through JavaScript and save it onto your device

After extensive research, I have hit a roadblock and desperately need help. My task involves downloading an HTML page by filling out a form with various data and submitting it to save the responses. Using Firebug, I can see that my data is sent over POST, ...

What is causing my radio button event to activate when a separate radio button is selected?

I have implemented the code below to display "pers" and hide "bus," and vice versa. JQuery: $('input[name="perorbus"]').click(function() { if ($(this).attr('id') == 'bus') { $('#showbus&apo ...

Different ways to determine if someone is currently using the internet or not

I'm working on a user profile feature for my website and I want to display each user's Skype status, indicating whether they are online or offline. How can I achieve this? ...

Webshot is unable to retain any images

I attempted to utilize the Node package Webshot. The function is being executed, "OK" is printed to the console, but no files are saved to the specified folder. What could I be overlooking? if (Meteor.isServer) { var webshot = Meteor.npmRequire(&apos ...

Safari MediaSource will not launch in a background tab

It seems like the issue I'm facing may be similar to the problem described in this Stack Overflow post: Changing <source> with HTML5 Audio works in Chrome but not Safari The specific problem I'm encountering is that when a MediaSource is a ...

Simplify an array for utilization in D3

Currently working on extracting data from mongoDB using javascript and React. In order to utilize D3.js effectively, I need to flatten the array. Presently, my data looks like this: [{ "location": [ { "createdAt": "2023-04 ...

Control the playback of individual HTML5 audio elements using jQuery for seamless user experience

How can I modify the code to ensure that only one HTML5 audio element plays at a time? Currently, all tracks are able to play simultaneously. I am using jQuery for play and pause functionalities. If one track is playing and another is clicked on, how can ...

The Socket.io server is experiencing issues with the "connection" event not firing, and the client event is also not being triggered

I've been struggling to set up an express backend with socket io. No matter what I try, the connection events just won't fire. Both the server and client are using version 3.1.2, so that's not the issue. When I start the client app, I see so ...

Adding static data along with fetched data in Vue.js: A simple guide

I am looking to include advertisement banners after every 5 items in the data displayed by my application. This means that for every scroll, you would see five fetched data items followed by an advertisement, and then another set of five fetched data items ...

Is there a jQuery function similar to toggle that accepts a boolean parameter?

I find myself frequently writing code similar to the following snippet. It essentially toggles an element depending on a certain condition. For instance, in this hypothetical scenario, the condition is "if the checkbox with id agree is checked and the inp ...

Unable to establish a connection with Metamask

Looking to connect to Metamask and retrieve the account balance: <!DOCTYPE html> <html> <head> <title>Testing Ethereum with Metamask</title> <meta charset="UTF-8"> <meta name=&quo ...

Navigating with React Router v6 beyond the confines of individual components

When using react-router v5, I would create the history object like this: import { createBrowserHistory } from "history"; export const history = createBrowserHistory(); Then I would pass it to the Router like so: import { Router, Switch, Route, Link } from ...

Comparing Android Development Platforms: Webservices, PHP or ASP.NET? And what about XML versus JSON?

Hey there! I'm currently working on my very first Android app and I'm looking to establish a connection with a remote MSSQL database to send and receive data. I have experience with both php and asp.net, so I'm wondering which one would be t ...

Retrieve information from another table based on specific criteria using Entity Framework and ASP.NET Core

I am looking to retrieve all posts where the images are marked as Approved false. Below are my two Models, Post and Image models: public class Post { public Post() { Images = new List<Image>(); } public int Id { get; set; } p ...