Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.6 KB

README.md

File metadata and controls

57 lines (37 loc) · 1.6 KB

Baby Query

Baby Query is a custom implementation of the popular JavaScript library Baby Query.

For information on how to get started and how to use Baby Query, please see Baby Query's documentation. For source files and issues, please visit the Baby Query repo.

Including Baby Query

Below are some of the most common ways to include Baby Query.

Browser

Script tag

<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/babyQuery.js'></script>

or for the minified version:

<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/babyQuery.min.js'></script>

In the script, including Baby Query will usually look like this:

import $ from 'baby-query'

If you need to use Baby Query in a file that's not an ECMAScript module, you can use the CommonJS syntax:

var $ = require('baby-query')

Node

To include Baby Query in Node, first install with npm.

npm install baby-query

For Baby Query to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as jsdom. This can be useful for testing purposes.

const $ = require('baby-query')
const { JSDOM } = require('jsdom')
const { window, document } = new JSDOM(`<p>Hello world</p>`).window
global.window = window
global.document = document
console.log($('p').text())

Personal Blog Roblog, resource for learning web development.