Code Monkey home page Code Monkey logo

jquip's Introduction

jQuery getting too big?

The primary goal of this project would be for the feedback/demand to kickstart jquery.com into re-organizing its code-base so it's more modular since we believe we've proved the most useful parts of jQuery is a fraction of its code-base.

To this end, follow this project if you want jquery.com to measure the demand for this. Another project with similar goals is http://ender.no.de/ - for node.js. JSLim is another project that takes a novel approach to reducing code size with advanced minification techniques.

Zepto.js is another great alternative to jQuery, it's fast, light and optimized for mobile/webkit browsers. It's a popular option for PhoneGap developers with full support for the Backbone.js, Underscore.js and Spine.js frameworks. It has very recently added support for the latest Safari, Chrome, Firefox and Opera browsers - it makes use of latest EcmaScript 5 APIs without shims so if this is your targetted market, we encourage you to try it.

Based on recent posts it does looks like jQuery wants to build a slimmer jQuery. Although we don't think giving a trim is going far enough, we hope they perform larger re-structural changes allowing us to use most of the useful parts at a fraction of their cost. Their recent conversations into future file size reduction do sound promising.

Introducing jquip - aka jQuery-in-parts. Build Status

Smaller, Lighter, Faster, more modular jQuery - include only the parts you want! Don't use it, Don't include it.

Minified & gzipped code sizes (v.03):

  • jquip.js (6.6k)
  • jquip.events.js (1k)
  • jquip.docready.js (.5k)
  • jquip.css.js (2.5k)
  • jquip.ajax.js (1k)

Query Engine options (not required for modern browsers)

  • jquip.q-min.js (.6k) - An extremely fast but limited query engine (see below)
  • jquip.q-qwery.js (2.6k) - A New fast replacement for Sizzle.js
  • jquip.q-sizzle.js (5.29k) - Sizzle.js

The core jquip.js is only 6.6KB (minified and gzipped) - a fraction of the size of jQuery.

Has 90% of the good parts of jQuery (rest to be added plugins as needed), small enough to drop-in as source saving an external js reference.

Automatically downloads parts needed for older browsers

Sizzle.js is only added on demand (if it's not already included) from cdnjs.com for browsers that need it (i.e. <=IE7) as we believe it's the optimal way to download shims for browsers that need it.

Most code has been ported from jQuery or Zepto.js and optimized where possible, e.g. internals use underscore's native _.each over jquery's slower $.each etc.

Licence: http://www.opensource.org/licenses/mit-license.php (Same as jQuery and Zepto.js)

Build customizable jquip packages with the jQuip Library Builder service

The jquip Simple Demo is also available to try online, whilst a version compiled with Google's Closure Library (Advanced mode) is in the repo.

Disclaimer

This is NOT an official jQuery.com project.

Code-base will now be more stable as we've reached our goal of jquip.js (with the events + docready plugins) working in Backbone.js, there are likely a few fixes still to be added but the core is close to feature complete and wont require the major refactoring done recently.

We would still like to hear feedback on issues/non-implemented core functionality so we can measure the API popularity of missing pieces.

News

v.03.1

  • Fixed $().html method to support DOM elements (for Backbone and other libraries)

v.03

  • Intended to be last code change to significantly effect the size and API in the core jquip.js
  • $.loadAsync(url,cb) script loader added to load plugin and user scripts on demand
  • For older browsers that don't have querySelector support, Sizzle.js is downloaded on demand from cdnjs.com
  • If the ajax plugin is included and browser doesn't have JSON, it is also downloaded from cdnjs.com
    • When all scripts loaded the callbacks registered in $.scriptsLoaded and $(callback) are fired
    • Although if docready plugin is installed, $(callback) is only called on DOMContentLoaded
  • Modern browsers won't need additional downloads, so $(callback) fires straight away or after any user scripts are loaded with $.loadAsync
  • Added Expr support with :hidden and :visible baked in. Further :expression support can be plugged in by extending $.Expr
  • In addition to :expr's, filtering can also be #id, tagName, .className or [attr=value]
    • $().is, $().not, $().filter and $().find take advantage of the above filtering + Expr support
  • $().show, $().hide and $().toggle improved. With css plugin it behaves like jQuery, without, it only checks the visibility of selected elements
  • css plugin improved to report correct dimensions on Height/Width/Left/Top methods
  • Remaining Advanced Closure issues resolved (ie tests pass in both) should be safe to compile jquip.js and plugins

v.02

  • We now are able to compile in Closure Compiler's advanced compilation mode! The minified output passes Backbone.js test suite and reports only 1 not implemented feature in Spine.js tests. We still have Closure Compiler warnings as a result of un-annotated methods which we'll look at adding in the near future.
  • The source code was modified (somewhat unnaturally) so it would work with the Closure Compiler, i.e. have all the API methods exported correctly.
  • The total code-size (min+gzip) for jquip and non-query plugins (i.e. docready,events,css,ajax,custom) is 9.67k in advanced mode and 9.86k in Simple mode.

v.01

  • Abstracted Events, pluggable query engines and new $().find and Events system courtesy of the much leaner implementation in Zepto.js, refactored to support multiple browsers.
  • We are now passing Backbone.js latest test-suite in all the latest browsers! Now included in the /test folder.
  • New Spine.js tests added as well, now passing all but 1 test (in latest browsers)
    • (we'll get to older IE browsers as soon as we find a PC with them installed :)
  • New Event system added as a plugin, now with abstracted events.
    • We expect most devs would want to include events, but can now be stripped if you dont.
  • Query engines are now pluggable and none are included by default but will auto detect window.Sizzle or window.qwery if available and automatically download Sizzle.js from cdnjs.com if a browser doesn't support document.querySelectorAll (i.e. <=IE7). Note: because there's no Sizzle.js it's important to be aware of limitations when relying on browsers native querySelector implementations, i.e. there are restrictions in IE8 where the HTML page must be in standards mode and Safari in quirks mode can't handle uppercase or unicode characters.

pre-alpha, first release

  • Customizable Library builder service at
  • Node js build scripts added to minify jquip with UglifyJS.
  • $.addConstructor is now $.hook
  • $.addPlugin is now $.plug
  • scrollLeft and scrollTop is now in the css plugin
  • Due to a request by the jQuery team we're no longer assigning the jQuery variable, you will now need to manually change this yourself on the first line of jquip.js: window.jquip = window.$ = (function()..

Roadmap

  • Getting jquip to work in Google Closure Compiler's advanced compilation mode without warnings so it can be used to programatically strip out dead code your application doesn't use for an even smaller footprint!
  • Add the Closure Advanced Compiler option to the jquip library service
  • Add missing shims to Abstracted Events (decided to add them after all due to popular demand)
  • Add caching to improve performance

What's in the box? - i.e. the 90% good parts

Methods marked with * are only partially implemented.

  • $(selector)
    • $(selector, context), $(element), $(array)
    • $(callback) requires docready plugin.

Methods operating on a $(selctor)

  • add
  • each
  • attr
  • removeAttr
  • get
  • toArray
  • data
  • append
  • appendTo
  • prepend
  • prependTo
  • before
  • insertBefore
  • after
  • insertAfter
  • toggle
  • hide
  • show
  • fadeIn and fadeOut - does so without animation, consider using jquery.animate-enhanced plugin*
  • eq
  • first
  • last
  • indexOf
  • slice
  • find*
  • not*
  • filter*
  • is*
  • remove
  • closest
  • val* - does not do checkbox, select, etc.
  • html
  • text
  • empty
  • addClass
  • removeClass
  • hasClass
  • parent
  • parents
  • parentsUntil
  • next
  • prev
  • nextAll
  • nextUntil
  • prevUntil
  • siblings
  • children
  • contents
  • serializeArray

static methods off $

  • $$ - querySelectorAll or query engine shim
  • $.each
  • $._each - Underscore's native each
  • $._indexOf - Underscore's indexOf
  • $._defaults - Underscore's defaults
  • $._filter - Underscore's filter
  • $.Expr - :hidden :visible now supported, can plugin other expressions as needed.
  • $.filter
  • $.dir
  • $.nth
  • $.sibling
  • $.grep
  • $.map
  • $.data
  • $.attrs
  • $.trim
  • $.isFunction
  • $.isArray
  • $.isWindow
  • $.isNaN
  • $.merge
  • $.extend
  • $.makeArray
  • $.hasClass
  • $.typeOf - safe type of a variable
  • $.loadScript - (url, callback [, async]) load an external script dynamically
  • $.loadAsync - load js async and call $(callback) or $.scriptsLoaded when all scripts have been loaded
  • $.scriptsLoaded - register callbacks to be fired when all async scripts have been loaded.
  • $.htmlFrag - creates a document fragment from a html string (name changed)
  • $.walk - traveres all childElems including self (predicateFn, [[, context], results])
  • $.query - query Engine i.r. doc.querySelector || queryEngine Shim
  • $.attrs - an elements attributes
  • $.unique - return a unique list of elements in document order
  • $.contains - parent element contains sibling

Plugins

Pick and choose the parts of jQuery when and add you use them.

Other parts of jQuery can be Added via Plugins which is simply a matter of copying or including the script after the core jquip.js.

Methods on $(selector)

  • bind
  • unbind
  • one
  • delegate
  • undelegate
  • live
  • die
  • trigger
  • $.bind
  • $.unbind

Helpers on $(selector)

blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error

yep, it's a plugin!

  • $.css
  • width
  • height
  • innerHeight
  • innerWidth
  • outerHeight
  • outerWidth
  • scrollLeft
  • scrollTop
  • $.camelCase

based on David Flanagan HttpUtils modfied to work like jQuery's ajax.

  • $.xhr (cross-browser XHR Native Object)
  • $.ajax
  • $.get
  • $.post
  • $.getJSON
  • $.getScript
  • $.formData - convert object hash into a url Encoded string component
  • $._template - Underscore's template
  • $.queryString - cached map of queryString variables
  • $.is[Tab|Enter|Shift|...] - static functions to detect named keys pressed, e.g. if ($.isEnter(e)) console.log("pressed enter")
  • $.cancelEvent - cross-browser fn to preventDefault() and stopPropogation(), returns false.

Plugin Authors (adding your own plugins)

Extending jquip:

  • plug(name, fn($)) - Register your own plugin, mutate $ to extend jquip.
  • bool $.hook (function(selector, contxt)) - Intercept the constructor request.
  • $.setQuery (function(selector, context)) - plugin your own query engine

You can also include Sizzle.js or qwery.js above jquip.js (using IE's conditional comments is a good approach), it will automatically be registered. The q-{queryEngine}.js plugins are also self-registering.

Intercept the $(){ .. } constructor and inject your own implementation. Return true to short-circuit. e.g: from the docready plugin:

$.plug("docready", function ($) { $.hook(function (selector, ctx) { if (typeof selector == "function") { this.ready(selector); return true; } }); ... });

Limitations

Many corner cases we feel that are not likely to be hit in normal development have been intentionally stripped out, it's therefore possible for older browsers to experience some issues if you code hits these edge cases.

In addition to its fluent API, jQuery does a lot of cross-browser normalization as well as sanitization and quarantine for edge cases in older browsers which no doubt makes it a safer but slower option.

Non supported examples:

  • Script tags in inserted HTML are not automatically evaluated
  • Attributes and event handlers of cloned html fragments are not copied across
  • Expression support is limited see v.03 release notes

We prefer not to take the perf and code-bloat hit of this quarantine - if your app does hit one of these edge cases you will either need to code a specific workaround for your apps usage (which will in all likely be more optimized than jQuery's general purpose solution) or simply move back to using jQuery.

Best Practices

Contrary to the strong-held opinions of many "javascript experts" DOMContentLoaded is rarely the fastest solution to run your app's logic. It is a safer option but in most cases your app will run faster if you execute your javascript somewhere below the HTML elements they reference even if it's at the bottom of your page it will fire before DOMContentLoaded which will no longer be required. This guidance is from the Google Apps and YUI developer teams (amongst others). If you can't control where user scripts are placed, DOMContentLoaded is still a suitable option. This answer on StackOverflow provides a good overview over when to use it.

We thought we'd clarify as we've received a lot of feedback (aka strong opinions) on this subject - this is why jQuery's popular docready is a plugin that's not included by default - simply include it as a plugin if you wish.

Similarly related, for best page load times you should move scripts to the bottom of your page, e.g. before the closing </body> tag.

If you're not referencing jquip near the bottom of your page and don't have either the events or docready plugins included, you should call $.onload() in your own post DOMReady event. It performs post processing tasks like downloading Sizzle.js (for <=IE7), calculates browser feature support, etc.

async script loading

As of v.03 the recommended approach to load scripts is now in $(callback) which gets fired right after all on async loaded scripts (inc user scripts) have been downloaded, which is still straight away for modern browsers (i.e. when no async downloads are needed). This recommendation can be ignored if you are only performing primitive queries (i.e. by #id, tag or .class) where querySelectorAll or Sizzle.js are not needed.

For older browsers (<=IE7) Sizzle.js is downloaded on demand, if ajax plugin is included JSON is also downloaded if it doesn't exist.

User and plugin scripts can be loaded dynamically with $.loadAsync(url, cb) which get loaded before $(callback) is fired. Additional scripts that are not needed on first page loaded can be downloaded with $.loadScript(url, cb).

Our recommendation for ultimate performance is to have a single reference to bundled and minified scripts needed immediately when the page is loaded. Followed by async downloading of all scripts required by your websites later.

Pre-fetching scripts needed on subsequent pages so its hot in your browsers cache is also a good idea.

Mini Query Engine (jquip.q-min.js)

Weighing at just 0.6k query-min is an ultra fast selector engine for browsers that don't provide native support for the querySelectorAll APIs (e.g. <=IE7). It works by offloading as much work as possible to the browsers primitive document.getElementById(), document.getElementsByTagName() and document.getElementsByClassName() apis.

On our last JavaScript heavy project, performance was improved by 7-8x in older browsers. If you're having performance issues with older browsers it's worth evaluating.

All selectors require an Id (i.e. #) Tag (e.g. INPUT) or class name in each child selector.

Valid Examples:

  • TBODY TD.c1 INPUT
  • TH.c1 STRONG
  • #btnSubmit SPAN
  • FORM INPUT[name='chkProcess']
  • FORM INPUT[type='text']
  • FORM INPUT[type]
  • FORM#id.a.b
  • FORM#id .a.b
  • .a.b.c
  • .a

For optimal performance in <= IE7, the first child selector should be a tag or an #id as it cuts down the amount of DOM traversing needed to be done in JavaScript since there is no document.getElementsByClassName() available.

jquip Library Builder Service

The project now includes the node.js /server/jquip.builder.js so you can host your own jquip Library builder service internally.

Contributing

I'd love help with this so Contributors and pull requests are very welcome!

The main task that needs doing is to get all the missing jQuery parts in as plugins and a comprehensive test suite so we can properly identify the parts of jQuery supported.

Feedback is welcome, drop me a line on @demisbellot.

Contributors

jquip's People

Contributors

bpneal avatar brendanmoore avatar fhahn avatar jeyb avatar mythz avatar naholyr avatar peanav avatar redolent avatar rspadim avatar solarissmoke avatar statianzo avatar thechriswalker avatar twolfson avatar xion avatar zipang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquip's Issues

A Typo in README.md

$isNaN should be $.isNaN.

I'm just a jQuery beginner so I'm learning from your code.

Firing custom events in IE 8 does not work

IE8's fireEvent will raise an 'Invalid Argument. ' for events that are not in its predefined list (onclick, onblur, etc.)

Fixing would require tracking events outside addEvent and bubbling them.

ClosureCompiler ADVANCED - Errors

I have been trying to compile jquip using Closure Compiler in Advanced mode simply by compiling jquip.js alone (no other plug-ins). I get a heap of warnings. Am I doing something wrong?

To re-create what I am trying to do go to:

http://closure-compiler.appspot.com/home

Run the closure compiler in ADVANCED & include the link to the raw jquip.js code:

https://raw.github.com/mythz/jquip/master/src/jquip.js

You can simply do this by adding this header to the top:

// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @code_url https://raw.github.com/mythz/jquip/master/src/jquip.js
// ==/ClosureCompiler==

You will get a log of warnings like this:

23: java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
Unexpected variable trimLeft$$inline_78
Node(NAME trimLeft$$inline_78): https://raw.github.com/mythz/jquip/master/src/jquip.js:745:73
: function(text){ return text == null ? "" : text.toString().replace(trimLeft, "").replace(trimRight, ""); };
Parent(CALL): https://raw.github.com/mythz/jquip/master/src/jquip.js:745:49
: function(text){ return text == null ? "" : text.toString().replace(trimLeft, "").replace(trimRight, ""); };

the list of errors / warnings will go on
...

I get the same results with closure.jar

Any help would be appreciated. Thanks for all the efforts you guys are putting into jquip I think it's a great idea.

does anyone knows how to upload images using jquip? i'm kind of stuck here.

here is my HTML form code:

<form id="uploadForm" enctype="multipart/form-data">
    <input type="file" id='files' name='file-imgs' ></input>
</form>

and here is my javascript code:

$.ajax({
	url: '/uploadImg_article',
    	type: 'POST',
   	cache: false,
    	data: new FormData($('#uploadForm')[0]),
    	processData: false,
    	contentType: 'multipart/form-data'
})

and....unfortunately , it didn't work. is there something wrong with my code ? or i just using the jquip ajax the wrong way. :/

thanks.

use strict

It might be useful to use strict to call out leaks and such.

$.width() throws error

I just downloaded version 2.0 (cc4cff1) and tried to compute the width of some DOM elements.

Browser: Chrome 15 on Windows 7

My code:

$('a').width(20);

I've included jquip.js, jquip.events.css and jquip.css.js right before the closing body tag of a simple HTML5 page.

Expected:

All links should have width:20px

Actual result:

Uncaught TypeError: Object #<$> has no method 'css'

Seems like the reference to this.css is broken:

// jquip.css.js line 164
return this.css(type, typeof size === "string" ? size : size + "px");

Greetings,
Christoph

Make jquip aware of CommonJS/AMD

I just threw jquip into my system instead of jQuery...and straight away saw a problem:

    ;$['plug']("ajax", function ($) {

This line throws an "$.plug is not defined" error. The entire code is wrapped in these lines:

/* 2 */
/***/ function(module, exports, __webpack_require__) {
    /* WEBPACK VAR INJECTION */(function($) {

    // ... snip. Jquip goes in here.

    /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
/***/ },

The __webpack_require__(2) resolves to that very module. This can, but does not have to, happen. A solution would be to replace first or second line of jquip with this:

// Original
    window['$'] = window['jquip'] = (function(){

// Replace
    var $ = window['$'] = window['jquip'] = (function(){

This way, we gain these things:

  • A local reference to the object that we are building. Previously polluted $'s will be shaddowed by this one.
  • We can figure out if we have module.exports present and return jquip this way, too.

At the start or end of jquip:

if(typeof module != "undefined" && typeof exports != "undefined") {
    // "return" the jquip instance.
    exports = $;
}

I am not very familiar with AMD, but the first 20 lines of jQuery show a good example on how to go about them.

For now I have to fall back to jQuery, since there is no appearant way I can monkeypatch this problem out without having to fork this project ... for one line, at most.

Mousemove events have no event target in IE8

This is probably an IE8 bug/limitation, but jQuery seems to work around it.

I'm trying to use the Chosen component with jQuip instead of jQuery. It seems to mostly work (apart from getting a 0px size initially, that I had to override manually), but mouse events don't work and generate an error, as you can see on this screenshot:

win7_ie_8 0

It seems that event.target is undefined for these events. Any ideas where can we get this from? Can jQuip work around this IE8 bug as jQuery does?

Minor incompatibility with Bootstrap Accessibility Plugin

The accessibility plugin for Bootstrap, developed by eBay/PayPal seems to be incompatible with jquip. The respective lines of failing code:

bootstrapaccessibilityplugin/src/js/functions.js:

      $.extend( $.expr[ ":" ], {

bootstrapaccessibilityplugin/src/js/alert.js:

    $('.close').removeAttr('aria-hidden').wrapInner('<span aria-hidden="true"></span>').append('<span class="sr-only">Close</span>')

bootstrap/src/js/modal.js:
This only happens when you trigger a modal. So far the first incompatible bootstrap part.

        var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })

bootstrap/src/js/dropdown.js:
This error happens when you trigger a dropdown.

$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))

Hopefully these could be resolved! :)

seems bug in data method

    function data(el, name, setVal){
        if (!el) return {};
        if (name && setVal){
            el.setAttribute(name, setVal);
            return null;
        }
        var o = {};
        _each(attrs(el), function(val, aName){
            if (aName.indexOf("data-") !== 0 || !val) return;
            o[aName.substr("data-".length)] = val;
        });
        if (isS(name)) return o[name];
        return o;
    } $['data'] = data;

by the above logic, you have to use this method like:

set: $.data(document.body, 'data-sample', 'sample')
get: $.data(document.body, 'sample')

which I don't think is the right way it's supposed to work.

append

The append function doesn't take into account that setting innerHTML requires the content to be properly nested. Example:

$('table').append("<tr><td>oh no</td></tr>");

Would result in the <tr> being stripped. jQuery get's around this by setting wrappers for the innerHTML and then picking the correct element down the tree.

Here is how I'm doing it: https://github.com/jeyb/jquip/commit/5a8a4aebe9a6d6b7e239117b45c23af172cf96c4

Would you be interesting in such an addition?

Working with jQuery Colorbox Plugin

Using jQuip with colorbox () produces this error:

jQuery is not defined

because of line 875 in jquery.colorbox-1.3.18.js:

 }(jQuery, document, this));

I'm not an expert javascript programmer, so how could the colorbox jQuery plugin be modified to support swapping in jQuip?

Move loadAsync pieces out of core

What are thoughts about moving the loadAsync parts out of core? It could help compatibility with those who are using other loaders and also trim some size.

jQuip.ajax doesn't accept the same arguments as jQuery

Hi, I've just started using jquip and am liking it! I noticed that the way $.ajax works in jQuip is slightly different to jQuery:

from http://api.jquery.com/jQuery.ajax/ :

jQuery.ajax( url [, settings] )

url A string containing the URL to which the request is sent.

settings A set of key/value pairs that configure the Ajax request. All settings are optional.

jQuip doesn't let you supply a URL as the first argument - it has to be supplied as part of the settings object. You get a fatal error if you use the jQuery syntax.

I'm not too fussed about whether or not you want to mirror this behaviour - but if not, it would be helpful to have a note about this in the readme, saying that the accepted arguments are different to jQuery?

jQuery 1.9 and 2.0 (IE 6/7/8)

We're currently evaluating jquip for our project and I was interested to find out what jquip will be doing when jquery releases 1.9 and 2.0 next year. As mentioned on their blog jQuery 2.0 will be removing IE 6/7/8 support which will require users to go with jQuery 1.9 if they need it.

I was wondering what jquip is planning to do when this happens as we're in a position where we handle analytics and monetization and every user matters even the ones stuck on ancient browsers.

JSON.stringify call in ajax() double encodes json from Backbone

Backbone's invocation of ajax() passes data that has been stringified.

if (!options.data && model && (method == 'create' || method == 'update')) {
  params.contentType = 'application/json';
  params.data = JSON.stringify(model.toJSON());
}

When ajax() is called, JSON.stringify is called again. This causes the string to get double encoded. For example: "{\"name\":\"ted\",\"age\":22}" Parsing that on the server turns into a string instead of an object.

I've created an example comparison between jQuery and jquip. Look at the payloads.

As for a solution, is the call to JSON.stringify necessary? It doesn't match the behavior of jQuery's ajax().

ajax cache

add this lines in jquip.ajax.js:

after:
var url = o['url'], data = null;
var isPost = o['type'] == "POST" || o['type'] == "PUT";
if( o['data'] && o['processData'] && typeof o['data'] == 'object' )
data = $'formData';
.......
insert this (the o['cache'] part):
.......
if (!isPost && data) {
url += "?" + data;
data = null;
if(o['cache']===false)
url=url+"&="+(new Date().getTime());
}else(!isPost && o['cache']===false)
url=url+"?
="+(new Date().getTime());
xhr.open(o['type'], url);
..........

support CommonJS and/or AMD

It would be awesome if the library supported CommonJS style modules and/or AMD (asynchronous module loading; preferred for web libraries I guess).

Both would make it easier to manage dependencies between modules, load dependencies on demand (or not), etc.There are many existing tools for loading, packing or serving such modules.

Mouseenter/Mouseleave don't appear to work

It appears that the helper events from Jquery, dont appear to work. The jquip src references these events as if they were native, but I'm pretty sure that the Jquery does some work with them... I'll look into it some more and see if I can create a solution.

Give jquip a handle function, in case a module needs to be loaded

I am using WebPack to compile my JavaScript resources and alike into a single JavaScript and CSS file. Long story short; I realized how jQuery takes ~250kb of my script. Now add the unoptimized bulk of Socket.IO (300kb) and Bootstrap (you can guess it...) and you sit in my situation with this at the top of the webpack output:

Version: webpack 1.8.9
Time: 3178ms
                                 Asset       Size      Chunks             Chunk Names
  3daa08fd071dfaad35ca6f2954714881.jpg    1.09 MB              [emitted]  
  f4769f9bdb7466be65088239c12046d1.eot    20.1 kB              [emitted]  
 fa2772327f55d8198301fdb8bcfc8158.woff    23.4 kB              [emitted]  
  e18bbf611f2a2e43afc071aa2f4e1512.ttf    45.4 kB              [emitted]  
  89889688147bd7575d6327160d64e760.svg     109 kB              [emitted]  
  f7c2b4b747b1a225eb8dee034134a1b0.eot    60.8 kB              [emitted]  
97493d3f11c0a3bd5cbd959f5d19b699.woff2    56.8 kB              [emitted]  
 d9ee23d59d0e0e727b51368b458a0bff.woff    71.5 kB              [emitted]  
  706450d7bba6374ca02fe167d86685cb.ttf     122 kB              [emitted]  
  2980083682e94d33a66eef2e7d612519.svg     313 kB              [emitted]  
  2516339970d710819585f90773aebe0a.png    12.8 kB              [emitted]  
448c34a56d699c29117adc64c43affeb.woff2      18 kB              [emitted]  
  089d2e0083252f402c6b5888fe27eab4.jpg    23.4 kB              [emitted]  
  98e3f8fbdac57fef3d6d239da334e924.png    69.3 kB              [emitted]  
  60031ca76bf60b012afc26c5a96c8b67.png    14.1 kB              [emitted]  
  0f24b53179ba5959ed8227eb79b8c97b.png    21.8 kB              [emitted]  
          6e57378d03faae1b5d08-main.js     716 kB        0, 2  [emitted]  main <--------- Gulp...
           1.6e57378d03faae1b5d08-1.js     508 kB        1, 2  [emitted]  
    6e57378d03faae1b5d08-libwebpack.js    3.76 kB           2  [emitted]  libwebpack
         6e57378d03faae1b5d08-main.css     260 kB        0, 2  [emitted]  main
       6e57378d03faae1b5d08-main.0.map  106 bytes  0, 2, 0, 2  [emitted]  main, main
          6e57378d03faae1b5d08-1.1.map     555 kB        1, 2  [emitted]  
 6e57378d03faae1b5d08-libwebpack.2.map     3.8 kB           2  [emitted]  libwebpack

So I found jquip. But if you thought a step ahead, you'd realize that WebPack is ment to compile everything at once, into one thing. It does have a function to asyncronously load additional chunks - and you can see that in the above output too. It contains the entireness of HighlightJS. it is loaded conditionaly, if there is one or more <code><pre>...</pre></code> sets present.

Now, imagine I dropped jquip in and lets just assume all the plugins and bootstrap would just work... what would happen, if I was to have a client with an older browser? jquip would normally load the Sizzle.js via cdnjs. But what, if I already bundled Sizzle and would want to intercept the sizzle download and instead just require and return it from an additional chunk of data, for example?

Therefore I am proposing a feature request, pretty much. It'd be awesome if you could have people get the ability to sneakily intercept these "if not exist then download" lines with something more fitting for their system - i.e., when using RequireJS already.

I hope to use jquip in the future and I will see how far I can get bootstrap to work ontop of it. Because it would be handy to strip away ~200KB of code I'd barely ever use.

Kind regards,
Ingwie!

.find() on mult-root document fragment gives warnings

Calling .find() on a document fragment with multiple roots will give TypeError:undefined_method warnings. For example:

$('<p>foo</p> <p class="yo">bar</p>').find('.yo')

The issue stems from the space character between the two <p> tags. That is considered to be a Text node and doesn't provide querySelectorAll as requested on jquip.js:534.

This only gives warnings and does not break functionality. However, limiting the number of exceptions occurring inside jquip could be a good thing.

Remove "jQuery" variable name

Many micro libraries have cropped up in the last year, all of them claiming some level of compatibility with jQuery, but none of them actually use the jQuery variable - because they are not jQuery. Using the jQuery Identifier variable is misleading to end developers and misrepresents your project as a simple drop-in replacement for jQuery, while also tacitly implying an endorsement by jQuery and/or jQuery core developers, which is not the case. We are taking the task of exploring approaches to reduce jQuery's size very seriously (Building A Slimmer jQuery, File Size Considerations ), but I think that distributing your own library with the name "jQuery" in it will only serve to confuse users, who will only be getting something that's "mostly like" the window.jQuery they're used to - if it is indeed your intention to actually have people use jQuip. If, as you mention in the readme, you're only doing this project to "measure the demand" for "jQuery into organizing its code to be more modular," you can be assured that we're already well aware of the demand, and are investigating ways to achieve that end without slashing the functionality jQuery's users expect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.