I've been tasked with removing some Javascript libraries from a website. I can't post the code here. Is there a tool or something that can point out the functions in the code that belong to JQuery.
The code is also using prototype. (One of the reason for removing jquery is to remove as 开发者_开发技巧asmuch external library references as possible and then settling on just one of them)
JQuery is one of the better and most used libraries (which means potential for better community support). It's probably the one you want to keep.
I don't know of any tools that will help you identify JQuery calls, but you can search for jquery
or $
. Also, just remove the library reference, and let the debugger point out all the errors in the code. Most of them should be calls to JQuery.
To fix the code you'd obviously need to rewrite some functions you were using in JQuery, or find the alternative in the library you are still using.
It will indeed be very hard to remove all the calls if you don't know which are using jquery.
I suggest this two options:
Remove jquery, and test your site, and check which functions are broken (very time consuming and prone to error, maybe use a crawler to do this). If you manage to find all the broken code, rewrite it in prototype.
Assuming jquery and prototype are running fine, but in case you decide to keep jquery, take a look at the
jQuery.noConflict();
this was created for situations like this, where two (or more) js libraries could "colide". Read more here: http://api.jquery.com/jQuery.noConflict/
good luck!
精彩评论