Aspnet优化js脚本 [英] Aspnet optimizing js scripts

查看:89
本文介绍了Aspnet优化js脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我如何优化加载网站的网页?

i有一个网站母版页和其他一些页面。

是否有办法,如何在导航后只加载页面内容通过a-tag,但主页面内容不会再次加载?

解决方案

你不能控制那样的东西。您没有下载页面,HTTP服务器和Web浏览器一起执行此操作。您只能控制页面的内容。



要理解它,您只需要了解Web操作。获取主页/内容页面。这是一种纯粹的服务器端技术,是众多技术中的一种。 ASP.NET的全部目的是动态地编写HTTP响应,以响应Web浏览器的HTTP请求。在客户端,总有一个页面。来自浏览器的HTTP请求有一些服务器采用的URI,ASP.NET组装页面,可以与主页面结合使用,还有更多(例如,从数据库中获取的当前数据,在飞,什么)。



同时,一组额外的文件被加载到不同的HTTP请求上。当HTML页面包含其他URI(例如图像文件,样式文件,JavaScript文件等)时会发生这种情况。与主页/内容页相比,每个单独的URI导致HTTP请求/响应的单独交换,与将所有资源嵌入单个HTTP页中相比,平均效率可能更低。但它只是在病理情况下才是真正的问题。通常,没有人试图认真优化它。可以嵌入CSS和JavaScript文件,但嵌入图像看起来不太真实。



您是否熟悉有关通用编程的评论建议:不要过早优化 ,不做手动优化,第一,关注正确的功能?这些都不是绝对的,但在你关心优化之前,你可能需要首先对网络有一般的了解。



-SA

Hi. How i can optimize loading site web pages?
i have a site master-page and some other pages.
is there a way, how i can load only page content after navigating by a-tag, but master-page content will not be loaded again?

解决方案

You cannot control anything like that. You are not downloading a page, HTTP server and Web browser do it together. You can only control the content of the pages.

To understand it, you just need to get some understanding of Web operation. Take master/content pages. This is a purely server-side technique, one of the many. Whole purpose of ASP.NET is to compose HTTP responses on the fly, in response to Web browser's HTTP request. On the client side, there is always one single page. The HTTP request from a browser has some URI which is taken by the server, and ASP.NET assembles the page, which can be combined with master page, and a lot more (for example, current data fetched from database, pictures composed on the fly, anything).

At the same time, a set of additional files are loaded on separate HTTP requests. This happens when the HTML page contains other URIs, such as image files, style files, JavaScript files, and so on. In contrast to master/content pages, each separate URI causes separate exchange of HTTP requests/response, which could be less efficient on average, compared to having all resources embedded in a single HTTP page. But it could be a real problem only in pathological cases. Normally, nobody tries to seriously "optimize" it. CSS and JavaScript files can be embedded, but embedding of images does not look realistic.

Are you familiar with comment advice on general programming: "don't optimize prematurely", "don't do manual optimization", "firs of all, care of correct functionality"? None of then is the absolute, but perhaps you need to get general understanding of the Web first, before you care of "optimization".

—SA


这篇关于Aspnet优化js脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆