{"id":15107563,"url":"https://github.com/ecromaneli/parasitejs","last_synced_at":"2025-09-27T05:31:44.170Z","repository":{"id":57318929,"uuid":"164239374","full_name":"ECRomaneli/ParasiteJS","owner":"ECRomaneli","description":"Use javascript the way you want, fast as possible.","archived":true,"fork":false,"pushed_at":"2020-02-09T14:26:50.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T13:27:23.458Z","etag":null,"topics":["ajax","dom","dom-manipulation","element","event-listener","jquery","jquery-like","lightweight","mquery","parasite","parasitejs","performance","vanilla"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ECRomaneli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-05T18:07:00.000Z","updated_at":"2024-06-21T13:05:45.000Z","dependencies_parsed_at":"2022-08-25T20:00:43.232Z","dependency_job_id":null,"html_url":"https://github.com/ECRomaneli/ParasiteJS","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FParasiteJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FParasiteJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FParasiteJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FParasiteJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ECRomaneli","download_url":"https://codeload.github.com/ECRomaneli/ParasiteJS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234391383,"owners_count":18824810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ajax","dom","dom-manipulation","element","event-listener","jquery","jquery-like","lightweight","mquery","parasite","parasitejs","performance","vanilla"],"created_at":"2024-09-25T21:25:30.985Z","updated_at":"2025-09-27T05:31:43.870Z","avatar_url":"https://github.com/ECRomaneli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align='center'\u003eParasiteJS\u003c/h1\u003e\n\u003cp align='center'\u003e\nUse javascript the way you want, fast as possible.\n\u003c/p\u003e\n\u003cp align='center'\u003e\n\u003cimg src=\"https://img.shields.io/npm/v/parasitejs.svg\" alt=\"module version\"\u003e\u0026nbsp;\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"GitHub license\"\u003e\u0026nbsp;\n    \u003cimg src=\"https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat\" alt=\"contributions welcome\"\u003e\n\u003c/p\u003e\n\n## Objective\nNow, more than ever, you do not need jQuery to manipulate HTML elements and their events. The ParasiteJS library consumes HTML elements, nodelists, and collections by adding key query and iteration functions, focusing on performance and agility in development.\n\n### Performance\nAll added functions aim to approach vanilla performance.\n\n### Agility in Development\nWhen talking about agility, vanilla is more inefficient than all query libraries (for this, they exist :P).\n\nThe javascript does not have functions to manipulate the lists returned by the search of elements (querySelectorAll, getElements ...) forcing you to create functions to do this.\n\nThe ParasiteJS functions are available in collections and elements making these functions always available into the elements. The functions are based on jQuery but are NOT compatible, so check out the documentation below.\n\n### Warning\nThis project does not objective the module creation. This is a lightweight and faster alternative than jQuery for \"Do not use jQuery\" projects where jQuery is not a dependency.\n\n## Install\n\n```shell\n    npm i parasitejs\n```\n\n## How to use\n### Module\nRequire ``parasitejs`` and he goes modify lists, collections and elements:\n```typescript\n    const { p$ } = require('parasitejs')\n\n    p$(() =\u003e {\n\n        // Same as document.find\n        let $el = p$('tag.class#id[attr=\"value\"]')\n\n        $el = $el.find('selector')\n\n        $el .findTag('tag')     // Return collection\n            .findId('id')       // Return element\n            .findClass('class') // Return collection \n            .find('selector')   // Return list\n            .css({ style: 'value' });\n\n    })\n``` \n\n### Web\nDownload script into **/dist/web/** folder and import normally:\n```html\n    \u003cscript type=\"text/javascript\" src=\"parasite.min.js\"/\u003e\n\n    \u003cscript\u003e\n        p$(() =\u003e { \n\n            // Same as document.find\n            let $el = p$('tag.class#id[attr=\"value\"]')\n\n            $el = $el.find('selector')\n\n            $el .findTag('tag')     // Return collection\n                .findId('id')       // Return element\n                .findClass('class') // Return collection \n                .find('selector')   // Return list\n                .css({ style: 'value' });\n\n        });\n    \u003c/script\u003e\n``` \n\n## Pseudo jQuery-like Function\nThe ParasiteJS create a variable called ``p$``. That provides static functions and an constructor.\n\n### jQuery-like Function\n```typescript\n    // Find selector and return collection\n    p$(selector: string): ParasitedList | NodeList | HTMLCollection\n\n    // on ready callback\n    p$(handler: Function): void\n\n    // Array of HTMLElements\n    p$(elemArr: HTMLElement[]): ParasitedList\n\n    // HTML Element\n    p$(elem: HTMLElement): ParasitedList\n```\n\n#### Static Helpers\n```typescript\n    // DOM Ready\n    p$.ready(fn: Function): void\n\n    // Each lists and collections with length\n    p$.each(list: ArrayLike\u003cany\u003e, iterator: (keyIndex: string|number, value: any) =\u003e boolean): ArrayLike\u003cany\u003e\n```\n\n#### Javascript Helpers\n```typescript\n    // Load other js files with javascript\n    p$.require(filePath: string): void\n\n    // Load javascript code\n    p$.globalEval(code: string): void\n```\n\n#### AJAX\n```typescript\n    // Ajax jQuery-like\n    p$.ajax(url?: string, settings: AJAXSettings): Deferred\n\n    // GET URL\n    p$.get(url: string, data?: any, success: AJAXSuccess): Deferred\n    p$.get(settings: AJAXSettings): Deferred\n\n    // POST URL\n    p$.post(url: string, data: any, success: AJAXSuccess): Deferred\n    p$.post(settings: AJAXSettings): Deferred\n```\n\n#### Promise\n```typescript\n    // Deferred jQuery-like\n    p$.Deferred(beforeStart?: Function): Deferred\n```\n\n## Functions\n\n### All\n```typescript\n    let obj: Document | HTMLElement | Window | NodeList | HTMLCollection\n\n    // Attach an event handler function for one or more events.\n    obj.on(events: string, selector?: string, handler: Function): this\n\n    // Attach a handler to an event for the elements.\n    // The handler is executed at most once per element\n    // per event type.\n    obj.one(events: string, selector?: string, handler: Function): this\n\n    // Remove an event handler.\n    obj.off(events: string, selector?: string, handler: Function): this\n\n    // Execute all handlers and behaviors attached.\n    obj.trigger(events: string, data?: any): this\n```\n\n### Document, HTMLElement, NodeList, HTMLCollection\n```typescript\n    let obj: Document | HTMLElement | NodeList | HTMLCollection\n\n    // Execute getElementById (and filter if needed).\n    obj.findId(id: string): Element | null\n\n    // Execute getElementsByName.\n    obj.findName(name: string): NodeList\n\n    // Execute getElementsByTag.\n    obj.findTag(tag: string): HTMLCollection\n\n    // Execute getElementsByClass.\n    obj.findClass(clss: string): HTMLCollection\n\n    // Execute querySelector.\n    obj.findOne(selector: string): Element | null\n\n    // Forced querySelectorAll.\n    obj.findAll(selector: string): NodeList\n\n    // Optimized querySelectorAll (just execute\n    // querySelectorAll if needed).\n    obj.find(selector: string): NodeList | HTMLCollection | ParasitedList\n```\n\n### NodeList, HTMLCollection\n```typescript\n    let list: NodeList | HTMLCollection\n\n    // Reduce the set of matched elements by selector\n    // or test function.\n    list.filter(selector: string | Function): ParasitedList\n\n    // Retrieve one of the elements matched.\n    list.get(index?: number): HTMLElement | void\n\n    // Iterate over the list, executing a function\n    // for each matched element.\n    list.each(handler: EachIterator): this\n```\n\n### HTMLElement\n```typescript\n    let elem: HTMLElement\n\n    // Set one or more attributes for the set\n    // of matched elements or get first element attribute.\n    elem.attr(attrs: PlainObject | string, value?: string): this | string\n\n    // Remove an attribute from each element\n    // in the set of matched elements.\n    elem.removeAttr(attrNames: string): this\n\n    // Set one or more properties for the set of\n    // matched elements or get first element prop.\n    elem.prop(props: PlainObject | string, value?: string): this | string\n\n    // Remove a property for the set of matched elements.\n    elem.removeProp(propNames: string): this\n\n    // Set the value of each element in the set of\n    // matched elements or get first element value.\n    elem.val(value?: string): this | string\n\n    // Store arbitrary data associated with the matched\n    // elements or get first element data.\n    elem.data(data: PlainObject | string, value?: string): this | string\n\n    // Get the computed style properties for the first\n    // element in the set of matched elements.\n    elem.css(styles: PlainObject | string, value?: string): this | string\n\n    // Check the current matched set of elements for\n    // selector or test function.\n    elem.is(filter: string | Function): boolean\n```\n\n## Author\n\n- Created and maintained by [Emerson C. Romaneli](https://github.com/ECRomaneli) (@ECRomaneli).\n\n## License\n\n- ParasiteJS:\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecromaneli%2Fparasitejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecromaneli%2Fparasitejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecromaneli%2Fparasitejs/lists"}