如何确定重复的JavaScript函数,其中包括在Asp.net页 [英] How to Determine duplicate Javascript Functions which include in Asp.net Page

查看:109
本文介绍了如何确定重复的JavaScript函数,其中包括在Asp.net页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用一些JavaScript函数的应用程序,

I have an application which use some javascript functions,

由于所有Javascript角包括在母版,其中大多数是随附withpage是没有必要的,而其中的一些被重复(在一些不同的JS文件中使用的原因)。

As all javascripts include in Masterpage, most of them which comes withpage are not necessary, and some of those are repeated ( cause used in some different JS file. )

所以我要检查是否有一种方法来确定重复的功能,并删除它们?

So I want to check if there is a way to determine duplicate functions and remove them ?

推荐答案

您可以检查是否声明函数时存在的功能,但你必须改变它的工作方式。

You can check if the function exists when declaring a function, but You have to change the way it works.

而不是

function foo(){ something }

DO

if(window.foo===undefined){
window.foo=function(){ something }
}

和你仍然可以把它叫做

foo();

这一切都可以在您使用查找和放大器的文件被添加;更换使用正则表达式,所以我认为这很容易:)

All this can be added in Your files with a find&replace using regexp, so I consider this easy :)

这篇关于如何确定重复的JavaScript函数,其中包括在Asp.net页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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