question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUEST] Making jQuery Optional

See original GitHub issue

This year, we’re going all-in on stripping down Ember to its bare essentials.

The first target in that effort is making jQuery optional, so applications that aren’t using jQuery don’t need to include the bulk. Successfully making jQuery optional cuts out around 30kb of minified/gzipped code, so it’s a very juicy target (it’s around 15-20% of the total size of an Ember app’s initial vendor.js!)

@rwjblue has done a lot of work so far on this front, and as of 28da357496089a34e5a59638e5d60220bd2b9d7d, the ember-application package tests clean without jQuery. Now it’s time to finish the job.

Testing Ember

If this is your first time working on Ember, you should follow these steps:

  1. Make sure you’re on the latest version of Node or the latest LTS of Node
  2. Update to the latest version of Yarn
  3. Clone https://github.com/emberjs/ember.js.git
  4. Run yarn to populate your node_modules
  5. Run yarn start
  6. Go to http://localhost:4200/tests/index.html?hidepassed in your browser.
  7. Edit packages in your editor and refresh the browser. Rinse, repeat.

Testing Ember Without jQuery

To test Ember without jQuery, you add in the jquery=none query parameter when running tests.

If you do that, you’ll get a bunch of failures, so we’re working on removing the dependency on jQuery one package at a time.

To test a single package without jQuery, run the tests by hitting this URL:

http://localhost:4200/tests/index.html?hidepassed&jquery=none&package=ember-glimmer

Making Progress

In order to make progress on removing the jQuery dependency, you need to satisfy two criteria:

  1. Fewer tests fail in jquery=none mode
  2. No tests fail without jquery=none

Making progress in this way means that incremental work can always be merged into master, because there are no regressions when using Ember the way it’s always been used.

Current Status and Work Items

I (@wycats) got the ember-glimmer package down to 20 failing tests on the no-jquery branch of https://github.com/wycats/ember.js.

However, I violated Rule 2 under “making progress” and broke a bunch of tests when running jQuery.

So some things you could work on:

  • Getting the tests passing again in normal mode in ember-glimmer
  • Getting any remaining tests passing with jquery=none in ember-glimmer
  • Get tests passing without jQuery
    • ember
      • component_context_test.js - 3 failing
      • link_to_test.js - 2 failing
      • multiple-app-test.js - 1 failing
      • reexports_test.js - 1 failing
      • basic_test.js - 38 failing
      • query_params_test.js - 23 failing
    • ember-application (@rwjblue)
    • ember-console
    • ember-debug
    • ember-extension-support
    • ember-glimmer (@ro0gr )
    • ember-metal
    • ember-routing
    • ember-runtime
    • ember-template-compiler (@ro0gr)
    • ember-testing (@snewcomer)
    • ember-utils
    • ember-views
    • internal-test-helpers
  • Switch packages to run in CI without jQuery (see https://github.com/emberjs/ember.js/commit/f71bbd07cacd406d3ac12db7d170be791b3a5c50 for an example)
    • ember
    • ember-application
    • ember-console
    • ember-debug
    • ember-extension-support
    • ember-glimmer
    • ember-metal
    • ember-routing
    • ember-runtime
    • ember-template-compiler
    • ember-testing
    • ember-utils
    • ember-views (not tested at the moment)
    • internal-test-helpers
  • RFC to allow users to opt out of jQuery (to make sure people not using jQuery get good errors if they or an addon try)
  • Make sure that error messages are good if people try to rely on jQuery features when jQuery is disabled
    • this.$() in Ember Components
    • pending requests in the test helpers (@rwjblue, does this work a different way with the new test helpers?)
    • Anything else?
  • Write an “opting out of jQuery” guide (like a deprecation guide, except jQuery is not deprecated yet) @emberjs/learning-team-managers

Not blockers for shipping the flag, but stuff we should work on before considering this feature “done”:

  • Figure out how to strip out all the extraneous noise of all of the jQuery imports in no-jQuery mode
  • Signify on Ember Observer that an addon does not depends on jQuery - 🔒 @kategengler

Hang Out in Community Slack

We’ll be coordinating this work on the community slack. You can join the #dev-jquery-removal channel.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:73
  • Comments:28 (28 by maintainers)

github_iconTop GitHub Comments

1reaction
simonihmigcommented, Jan 12, 2019

I would think this can be closed?

1reaction
rwjbluecommented, Jan 5, 2018

Once we get a package passing, it should be “locked” down in the lib/packages.js so that CI runs it both with and without jQuery.

See https://github.com/emberjs/ember.js/commit/f71bbd07cacd406d3ac12db7d170be791b3a5c50 for where this was initially setup…

Read more comments on GitHub >

github_iconTop Results From Across the Web

[QUEST] Making jQuery Optional #5320 - emberjs/data - GitHub
This issue tracks making jQuery optional in the Ember Data component of Ember. As a general principle, there are a few different kinds...
Read more >
quest for the ultimate inline wysiwyg using jQuery
Well I've been working with contentEditable in combination with a javascript library called Rangy. It's far from perfect, but it does the job....
Read more >
Make jQuery optional - Ember RFCs
This RFC proposes making jQuery optional and having a well defined way for ... For the past Ember has been relying and depending...
Read more >
jQuery validation of select elements where multiple=”multiple”
To this, we want to add some validation to make sure that at least one element in the list is selected when the...
Read more >
XMLHttpRequest.open() - Web APIs | MDN
An optional Boolean parameter, defaulting to true , indicating whether or not to perform the operation asynchronously.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found