我应该嵌入在Web应用程序的CSS / JavaScript文件? [英] Should I embed CSS/JavaScript files in a web application?

查看:239
本文介绍了我应该嵌入在Web应用程序的CSS / JavaScript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始嵌入JavaScript和CSS文件到我们的公共库DLL文件,使部署和版本控制简单了很多。我只是想知道如果有任何的原因之一可能想要做同样的事情与Web应用程序,或者如果它总是最好见好就收他们作为Web应用程序的常规文件,并且只能使用内嵌资源共享组件?

I've recently started embedding JavaScript and CSS files into our common library DLLs to make deployment and versioning a lot simpler. I was just wondering if there is any reason one might want to do the same thing with a web application, or if it's always best to just leave them as regular files in the web application, and only use embedded resources for shared components?

会不会有任何优势,它们嵌入?

Would there be any advantage to embedding them?

推荐答案

当然,如果有人谁知道他们在做什么可以用汇编反射并提取JS或CSS。但是,这会比只使用类似Firebug的东西来获得这方面的信息大量的工作赫克。定期最终用户不太可能去这一切麻烦的只是混乱与资源的愿望。任何人谁是有兴趣在此类型的事情很可能是一个恶意用户,而不是最终用户。您可能已经得到了很多其他问题,关于安全性,如果用户能够使用的工具,像你的DLL的程序集反射,因为到那个时候您的服务器已受到损害。安全性是不是在我的嵌入的资源决定因素。

Of course if anyone who knew what they were doing could use the assembly Reflector and extract the JS or CSS. But that would be a heck of a lot more work than just using something like FireBug to get at this information. A regular end user is unlikely to have the desire to go to all of this trouble just to mess with the resources. Anyone who's interested in this type of thing is likely to be a malicious user, not the end user. You have probably got a lot of other problems with regards to security if a user is able to use a tool like the assembly reflector on your DLL because by that point your server's already been compromised. Security was not the factor in my decision for embedding the resources.

问题的关键是保持从做一些愚蠢与这些资源的用户,如删除它们认为他们并不需要或与他们篡改,否则

The point was to keep users from doing something silly with these resources, like delete them thinking they aren't needed or otherwise tamper with them.

这也是一个容易得多,因为有涉及较少的文件打包部署目的的应用程序。

It's also a lot easier to package the application for deployment purposes because there are less files involved.

这是真的,在页面中使用的DLL(类库)较大,但这不会使任何网页更大。 ASP.NET产生需要被发送到客户端(浏览器)的内容。没有被发送到客户机比所需要的用于在网页的工作更多的内容。我怎么看不到客户端和服务器之间发送的类库帮助满足这些页面将对数据的大小没有任何影响。

It's true that the DLL (class library) used by the pages is bigger, but this does not make the pages any bigger. ASP.NET generates the content that needs to be sent down to the client (the browser). There is no more content being sent to the client than what is needed for the page to work. I do not see how the class library helping to serve these pages will have any effect on the size of data being sent between the client and server.

不过,Rjlopes有一个点,它可能是真实的,浏览器不能够缓存嵌入的JavaScript / CSS资源。我得看看,但我怀疑Rjlopes是正确的:JavaScript的/ CSS文件将有一整页回发到服务器的每次下载。如果这被证明是真实的,这种性能损失应该是你的决定的一个因素。

However, Rjlopes has a point, it might be true that the browser is not able to cache embedded JavaScript/CSS resources. I'll have to check it out but I suspect that Rjlopes is correct: the JavaScript/CSS files will have to be downloaded each time a full-page postback is made to the server. If this proves to be true, this performance hit should be a factor in your decision.

我还没有能够使用嵌入资源,resex和单文件,因为我一直在努力,一直忙于我的测试性能差异。希望因为我这个和浏览器缓存点Rjlopes已经提出很好奇,我会得到它今天晚些时候。

I still haven't been able to test the performance differences between using embedded resources, resex, and single files because I've been busy with my on endeavors. Hopefully I'll get to it later today because I am very curious about this and the browser caching point Rjlopes has raised.

这篇关于我应该嵌入在Web应用程序的CSS / JavaScript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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