npm-dom / domquery

jQuery-like handy DOM manipulation library composed from small modules in NPM.
http://npm.im/domquery
83 stars 8 forks source link

Instructions for using this in the browser #4

Closed simonexmachina closed 8 years ago

simonexmachina commented 10 years ago

I realise that I can probably use browserify, but I'm not really familiar with that. It'd be great if there were some instructions on how to use domquery in the browser.

simonexmachina commented 10 years ago

I just created a naive browserify bundle using browserify index.js -o bundle.js and it comes out at 44K (11K gzipped). Does that sound about right, or is this including code that doesn't need to be included?

MattiSG commented 9 years ago

Yup. The usage examples are really not clear.

If I'm supposed to use this within Node, how can I tell the library the context? How can I load a specific HTML file?

If I'm supposed to use this within the browser, how am I supposed to bundle it from an NPM node-modules folder?

azer commented 9 years ago

The documentation assumes that people who want to use it are familiar with browserify, we should add more docs for people getting started...

azer commented 9 years ago

just added this note: https://github.com/npm-dom/domquery/commit/1dd7104e57d304c7acef543fe9886670a353572a

MattiSG commented 9 years ago

Better than before! This just leaves an ambiguity: is it possible to use it in another context (i.e. not in the browser)?

azer commented 9 years ago

of course not, it's made for DOM

MattiSG commented 9 years ago

Well, as obvious as it seems to you, it would probably be worth including in the README :)

It doesn't strike me as stupid to consider doing DOM-like manipulation on the backend. I would love to have a library that lets me load an HTML file/stream and manipulate it as easily as on the frontend.

azer commented 9 years ago

cheerio does that: https://www.npmjs.org/package/cheerio

MattiSG commented 9 years ago

Thanks ;) that was just an explanation of why I think the expected usage should be more detailed :)

azer commented 9 years ago

arright, added another commit for that: https://github.com/npm-dom/domquery/commit/3a5f8d4ea61f90868aa6c76a74057bdae60d7116

MattiSG commented 9 years ago

Straight to the point :wink: