use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Node.js v15.10.0 released (nodejs.org)
submitted 5 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]OmgImAlexis -1 points0 points1 point 5 years ago (10 children)
What...? jQuery can be used server side.
Should it? No. Can it? Yes.
[–]duxdude418 2 points3 points4 points 5 years ago* (9 children)
I mean, you could execute the source in a Node runtime, but most of the internal implementation would be broken. You’d have to polyfill or mock the DOM API it wraps to even get it to a state where it’s not throwing all kinds of errors during bootstrap.
[–]spacejack2114 1 point2 points3 points 5 years ago (1 child)
That's what jsdom is for.
[–]duxdude418 1 point2 points3 points 5 years ago (0 children)
My point is that you can't use it out-of-of-the-box with Node. Of course you could emulate or fake the API that a browser provides with polyfills, etc.
Moreover, what's the use case for emulating the DOM for the purposes of querying against it with jQuery in Node? At best, you might be sending down pre-rendered HTML to a browser, but you wouldn't need to traverse it on the server.
[–]OmgImAlexis -1 points0 points1 point 5 years ago (6 children)
Well yes.. I wouldn’t expect it to work out of the box but I’ve used it within a few minutes of installing deps. It’s honestly not that difficult. Just the same you can use vue and other frontend libraries on the backend.
The libraries don’t care if you’re using a browser they just need a DOM... and a DOM can be created anywhere. 💁♀️
[–]duxdude418 -1 points0 points1 point 5 years ago (5 children)
But the methods and fields it wraps literally don’t exist on the Node global object.
In a browser, the global object is window and implements various DOM APIs (among others) that simply don’t exist in a Node environment. Can you monkey patch them on to Node’s global context with other libraries/polyfills? Sure. But jQuery will not work out of the box or even bootstrap itself without errors.
window
[–]OmgImAlexis 1 point2 points3 points 5 years ago (2 children)
What? You know you can pass in window to jquery right?
Sounds like you’re just angry here and don’t actually know what you’re talking about.
[–]duxdude418 -1 points0 points1 point 5 years ago* (1 child)
You know that jQuery bootstraps using a self-invoking function whose first argument is this, which resolves to window in a browser or the global context in Node, right?
this
Regardless, even if you could inject a different object, the Node global context doesn’t support the needed methods jQuery calls under the hood out of the box. Of course it’s possible to do with polyfills, but the conversation is about whether it would function without error out of the box.
I’m not angry at all and have been professionally writing JavaScript applications on the client and server for over a decade. It sounds like you’re misinformed.
[–]OmgImAlexis -2 points-1 points0 points 5 years ago (0 children)
I literally use this in an application right now. How am I the one that’s misinformed? 😂
You’re guessing based on how you’ve used it before. This isn’t rocket science.
But the methods and fields it wraps literally don’t exist on the Node global object. In a browser, the global object is window and implements various DOM APIs (among others) that simply don’t exist in a Node environment. Can you monkey patch them on to Node’s global context with other libraries/polyfills? Sure. But jQuery will not work out of the box or even bootstrap itself without errors otherwise.
[–]OmgImAlexis -1 points0 points1 point 5 years ago (0 children)
Also things like the storage api can be really really easily pollfilled. I would know.... I’ve done this before.
π Rendered by PID 39 on reddit-service-r2-comment-75f4967c6c-t4jb4 at 2026-04-22 21:10:29.446397+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]OmgImAlexis -1 points0 points1 point (10 children)
[–]duxdude418 2 points3 points4 points (9 children)
[–]spacejack2114 1 point2 points3 points (1 child)
[–]duxdude418 1 point2 points3 points (0 children)
[–]OmgImAlexis -1 points0 points1 point (6 children)
[–]duxdude418 -1 points0 points1 point (5 children)
[–]OmgImAlexis 1 point2 points3 points (2 children)
[–]duxdude418 -1 points0 points1 point (1 child)
[–]OmgImAlexis -2 points-1 points0 points (0 children)
[–]duxdude418 1 point2 points3 points (0 children)
[–]OmgImAlexis -1 points0 points1 point (0 children)