Is there any easy way to check where jQuery is used?

Asked 1 years ago, Updated 1 years ago, 55 views

Hello.

I am looking for a part of the website that I am currently using to write code using jQuery.

For now, I am searching by opening the html file in a text file and using the key "$(".

However, there are many html and PHP files, which make me feel uncomfortable.

Is there a good way to find out where jQuery is used?
Also, please let me know if you have any tools.

Thank you for your cooperation.

P.S.
Work environment (including development): Windows 7 Pro Website: Rental Server (CentOS)

I also download HTML and PHP files to my computer using FTP software.

javascript jquery windows

2022-09-30 20:33

5 Answers

There are many people who use tools to find them, but even JavaScript solutions.
After reading jQuery, create a $ proxy and stock the stack trace of the error object.

window.$=function(){
  vare = new Error();
  console.log(e.stack);
  jQuery.apply(jQuery, arguments);
}

You can now enumerate $('...').This is not the case when you reuse an instance, but also when you use other tools.


2022-09-30 20:33

Windows command prompts are typically findstr command.The function is very poor, but this is equivalent to grep.
findstr\$\(*.php*.html*.js allows you to search for all php and html and js files in the directory.
If you want to recursively search all subdirectories, use the /s option to findstr/s\$\(*.php*.html*.js.
/n optionally with a line number findstr/n/s\$\(*.php*.html*.js is useful for future reference.

If you are a GUI fan, most of the text editors and IDEs for programmers have the ability to search across files, so you should use them.xyzzy mentioned by ironsand is one of them.
I personally recommend Merry, which is listed under [Search]→[Search by File...] and can jump to the appropriate line from the search results with tag jump macro.


2022-09-30 20:33

For Windows PowerShell, you can use the Select-String command to view the search results for string patterns as filenames, lines, and the contents (string) of those lines.

I think you can find it in bulk, so I think it would be better to print it out to a txt file with >result.txt as shown below.

Get-ChildItem-Recurse-Include "*js", "*.htm", "*.html", "*.php" | Select-String-Pattern" \$\(">result.txt

Get-ChildItem

Obtain a list of files for the destination.

-Recurse—Finds the file recursively, including subdirectories.
-Include—Path element pattern.

Select-String

-Pattern—Allows regular expressions to be used in the character pattern you look for.

Select-Object

If you want to know only the location (file and number of lines) used, you can print only the path and number of lines in Select-Object Path, LineNumber.

Get-ChildItem-Recurse-Include "*js", "*.htm", "*.html", "*.php" | Select-String-Pattern" \$\(" | Select-Object Path, LineNumber > result.txt


2022-09-30 20:33

I use grep on Macs and Linux, but Windows doesn't have it as a standard, so why don't you use an alternative software?

I'll give you a few.

  • cygwin
    Unix-related commands will now be available on Windows.

Move the command to the appropriate directory on the command line

 grep-r --include=*.html --include=*.php --include=*.htm --include=*.js"$("

will be

  • Windows Grep
    I'm not using it, but it seems that I can use grep using the GUI on Windows.

  • xyzzy

Windows Grep
I'm not using it, but it seems that I can use grep using the GUI on Windows.

xyzzy

The feature in the editor implements grep.
After startup, Alt+x accepts command input, so typing grep-dialog opens a search dialog.

Please refer to the detailed explanation here.
http://xyzzy.s53.xrea.com/wiki/index.php?QuickTour%2Fgrep


2022-09-30 20:33

grep has already been introduced, so
A little minor, but more intuitive alternative tools such as ack, ag, and pt.
All of these are

$<command name><patterns you want to search for>directories you want to search for>

It can be used in .
Take ack as an example, after opening a command line and navigating to the folder of the files you want to search for

$ack"$(".

Then, the hit part of the file will be displayed.

Learn how to deploy each tool for Windows.

ack

Chocolate Gallery|Ack!2.14

It is probably easiest to deploy the Chocolate Package Manager for Windows.To deploy this tool, copy the command line at the top of the Chocolate Gallery or the installation command for PowerShell in your environment.
The choco command is now available, where ack is

$choco install ack

available on the .

ag (The Silver Seacher)

Same functionality as ack and is claimed to be faster.ack is also available from Chocolate.(But it's old)

The Silver Searcher windows port

Alternatively, there are people who have unofficially published exe for Windows even though it is not the latest version.(Thanks to other tools he created, I am responsible for using exe.)

Place the exe in the above site down the path.

pt (The Pratinum Searcher)

There is also a pt created with go in reference to ag.

Created ag(The Silver Searcher)-like fast search tool in Go language.EUC-JP/Shift-JIS is also searchable. - Thinking-megane

The good thing about this is that it is easy to prepare binaries for various operating systems because it is written in go, and you can actually get binaries for Windows from the above URL.(I tried the Linux binary on hand and got an error, but it may depend on the environment.)

Each has its own source code published on the github and can be built manually, but this time I think it's too much, so I'll skip it.


2022-09-30 20:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.