Skip to content

[QUEST] Making jQuery Optional #16058

Closed
Closed

Description

@wycats

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 28da357, 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 f71bbd0 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.

Activity

  1. self-assigned this
    on Jan 5, 2018
  2. wycats commented on Jan 5, 2018

    @wycats
    MemberAuthor

    If you want to help get my branch passing in normal mode, follow the same instructions for contributions, but target https://github.com/wycats/ember.js/tree/no-jquery

  3. topaxi commented on Jan 5, 2018

    @topaxi
    Contributor

    I'm not sure if this matters at all, but if you want access to https://github.com/topaxi/ember-jquery and it's npm package or even move it somewhere please contact me :)

  4. wycats commented on Jan 5, 2018

    @wycats
    MemberAuthor

    @topaxi what does that package do right now?

    I assume you're thinking we can use it to let people opt into the original functionality?

  5. wycats commented on Jan 5, 2018

    @wycats
    MemberAuthor

    I'm actively working on getting my own branch passing again.

  6. alexander-alvarez commented on Jan 5, 2018

    @alexander-alvarez
    Contributor

    I took a look through and ember-debug & ember-console have no references to jQuery

  7. ro0gr commented on Jan 5, 2018

    @ro0gr
    Contributor

    I've checked all the packages w/ and w/o jquery. Here are packages that pass:

    • ember-console (no tests)
    • ember-views (no tests)
    • ember-debug
    • ember-metal
    • ember-runtime
    • ember-utils
    • internal-test-helpers
  8. ro0gr commented on Jan 5, 2018

    @ro0gr
    Contributor

    I would like to pick ember-routing package

  9. rwjblue commented on Jan 5, 2018

    @rwjblue
    Member

    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 f71bbd0 for where this was initially setup...

  10. acorncom commented on Jan 6, 2018

    @acorncom
    Contributor

    Looks like ember-views and internal-test-helpers can be switched over to run in CI without jQuery. I've added a separate todo for ensuring all these packages are locked down

    Edit: was looking at an older version of the packages.js file, we're down to four modules

  11. wycats commented on Jan 6, 2018

    @wycats
    MemberAuthor

    @acorncom woot woot

  12. wycats commented on Jan 6, 2018

    @wycats
    MemberAuthor

    I got the tests passing on my branch, but for some reason tests are failing in IE11.

    I'm off for the evening, but I'd love a PR to get things passing on IE11. If nobody tackles it, I'll try to wrap it up later this weekend 😄

  13. RobbieTheWagner commented on Jan 7, 2018

    @RobbieTheWagner
    Member

    Anything I can help with? 😄

  14. wycats commented on Jan 7, 2018

    @wycats
    MemberAuthor

    @rwwagner90 do you think you can take a look at the IE11 bug on my branch?

  15. 1 remaining item

  16. topaxi commented on Jan 7, 2018

    @topaxi
    Contributor

    @wycats ember-jquery just includes jquery into the vendor bundle (it also allows for including the slim version jquery-slim instead of the full jquery build).

    Yes, it was my thought that it might be used for opt-in to the old behavior.

  17. RobbieTheWagner commented on Jan 7, 2018

    @RobbieTheWagner
    Member

    @wycats is it just the browserstack failures you wanted me to look at? It seems that the first 4 jobs are failing on Travis, but not sure if they are related.

    I tried running the browserstack tests locally, but couldn't seem to get it to work. Would you recommend setting up a VM for IE? I don't generally test in IE.

  18. kategengler commented on Jan 7, 2018

    @kategengler
    Member

    @rwwagner90 (and others looking to test other browsers), Microsoft provides virtual machines for testing Edge & IE https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

  19. rwjblue commented on Jan 8, 2018

    @rwjblue
    Member

    Just landed the ember-glimmer changes that @wycats has been working on, and unlocked the ember-glimmer package above.

    Anyone have time to pick up where @wycats left off and push ember-glimmer without jQuery over the finish line?

  20. wycats commented on Jan 8, 2018

    @wycats
    MemberAuthor

    @rwjblue @snewcomer what do we need to do to land #16075 ?

  21. RobbieTheWagner commented on Jan 10, 2018

    @RobbieTheWagner
    Member

    @rwjblue still looking for help with ember-glimmer? I've never looked at the code there, but I can try to help 😄

  22. wycats commented on Jan 10, 2018

    @wycats
    MemberAuthor

    @rwwagner90 looks like @ro0gr finished it here: #16096

    Confirming!

  23. ro0gr commented on Jan 10, 2018

    @ro0gr
    Contributor

    @rwwagner90 @wycats yes, ember-glimmer is finished. The only remaining package is ember. I've took a brief looks there.
    There are quite many failures. Most of them are straightforward to fix. However I think it might make sense to decouple.

  24. wycats commented on Jan 10, 2018

    @wycats
    MemberAuthor

    @ro0gr decouple in what way?

  25. ro0gr commented on Jan 10, 2018

    @ro0gr
    Contributor

    @wycats I think to decouple per file is good enough. If somebody wants to do all in once he still can.
    Here is the current state of ember package with jquery disabled:

    • packages/ember/tests/component_context_test.js - 3 failing
    • packages/ember/tests/helpers/link_to_test.js - 2 failing
    • packages/ember/tests/integration/multiple-app-test.js - 1 failing
    • packages/ember/tests/reexports_test.js - 1 failing
    • packages/ember/tests/routing/basic_test.js - 38 failing
    • packages/ember/tests/routing/query_params_test.js - 23 failing
  26. wycats commented on Jan 11, 2018

    @wycats
    MemberAuthor

    @ro0gr thanks! I updated it!

  27. wycats commented on Jan 15, 2018

    @wycats
    MemberAuthor

    @emberjs/learning-team-managers there will be some additional instructions for Ember Data:

    warp-drive-data/warp-drive#5320 (comment)

  28. wycats commented on Jan 15, 2018

    @wycats
    MemberAuthor

    Is there anything left on the error message front?

  29. simonihmig commented on Jan 12, 2019

    @simonihmig
    Contributor

    I would think this can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions