Problem/Motivation

The Blazy library has no dependency, but the module uses jQuery to initialize it.

The use of library like jQuery is to reduce dev time, coping with issues such as cross-browser compatibility, and above all DRY stuffs. AFAIK, most vanilla JavaScript plugins repeat themselves with similar methods since they don't use a library. Another reason why the module uses jQuery was most supported modules use them: Colorbox, Photobox, Slick. Blazy has also features like media switchers which use jQuery for most.

Specific to Slick, it has already a vanilla version, but hardly updated this far:
https://github.com/kenwheeler/slick/issues/494
At least a hope for a vanilla.

Proposed resolution

Consider using vanilla JS, at least for the main initialization for now.
The admin and contrib integration stuffs can follow later when the supported plugins drop jQuery as well.

Remaining tasks

  • Figure out common method replacements for:
    .once()
    .extend()
    etc.
  • Also make them re-usable for the supported integration with some contribs. Perhaps consider a pluggable and reusable plugin separate from the main initialization script. No need to re-invent the wheels, there are already tons of solutions.
  • IE8 can use core/classList polyfill only if needed. Probably not, seeing the only use of it is always doable with plain JavaScript. Drupal 8 doesn't support IE8 below, what a breeze: https://www.drupal.org/node/1569578, #1787012: [policy, no patch] Write D8 JS against ECMAScript 5. Prevent errors with feature detection (drop IE8 support).
  • In the future, we may consider Cash, or Underscore (in core already) to DRY. In the mean time, we cannot use them as they will add weights while jQuery is in use for most supported integration. A cherry-pick is reasonable in the least.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

gausarts created an issue. See original summary.

gausarts’s picture

Issue summary: View changes
gausarts’s picture

Issue summary: View changes
gausarts’s picture

Issue summary: View changes
gausarts’s picture

Status: Active » Needs review

First stub. Tested against IE9 and IE11, Chrome, FF, and latest related contribs: GridStack, Mason, Slick, Slick Browser, Blazy Photowipe.
Not tested against IE10, Safari, Opera as I have none.
If anything I am not aware of, please shed some light. Thanks.

gausarts’s picture

StatusFileSize
new19.46 KB

Somebody, likely me, forgot to attach the patch.

gausarts’s picture

Issue summary: View changes
StatusFileSize
new30.36 KB

Made Blazy Media use vanilla JS as well. Slick related stuffs should be moved into Slick.

  • gausarts committed 39a4418 on 8.x-1.x
    - #2838213 by gausarts: Use vanilla JS.
    
gausarts’s picture

Status: Needs review » Fixed

No news is good news. If any issue with this change, feel free to create a new issue.
Committed for wider tests.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.