Question

I was just making an userscript. I don't use jQuery on my own pages, but it saves lot of file size in userscripts - so I usually first check whether $ is defined.

On my particular page it was defined, so I started using it. When I first ran the code, it failed. So I kept investigating how does it come that jQuery isn't defined in my userscript.

Soon, I found out that the $ thingy is no jquery:

>>> $.toString()

"function () {
    [native code]
}"

But what the hell is it than? Browser fallback when jQuery is undefined? I don't think so.

This might be browser related thing.

Was it helpful?

Solution

It is a command line api function. Since $ is a valid variable name, they've used that.

Actually it is a shortcut or alias for document.querySelector(), so it might be confused for jQuery but actually it isn't.(Obviously, if jQuery isn't included)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top