Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stBorchert created an issue. See original summary.

stBorchert’s picture

Status: Active » Needs review
FileSize
23.76 KB

And here is the promised patch.

stBorchert’s picture

Updated patch with composer.json.

stBorchert’s picture

Whoa, forget to remove the test string in the loading area ...

stBorchert’s picture

FileSize
24.51 KB

Finally ...

SteffenR’s picture

Assigned: stBorchert » Unassigned

Hi stborchert,

I'm just testing your d8 port of views_lazy_load - looks great and works "like charm" / same loading experience as in drupal 7.
Would be great to have this patch in a new 8.x-1.x branch of the module to use it in a recent project, that relies on a composer based workflow.

Thx for sharing.

benjy’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Needs work

I've created the 8.x-1.x branch and enabled testing. We'll want to convert the test here before we commit it. Additional feedback below.

  1. +++ b/js/views_lazy_load.js
    @@ -0,0 +1,36 @@
    +  Drupal.behaviors.ViewsLazyLoad = {};
    +  Drupal.behaviors.ViewsLazyLoad.attach = function () {
    +    if (drupalSettings && drupalSettings.views_lazy_load) {
    

    Convention in core is for this to be:

      Drupal.behaviors.viewsLazyLoad = {
        attach: function (context, settings) {
    

    then we can use the local settings instead of the global drupalSettings I believe.

  2. +++ b/src/Plugin/views/display_extender/LazyLoadDisplayExtender.php
    @@ -0,0 +1,180 @@
    +      // Remove library?
    

    The library is been added below so this comment isn't relevant anymore.

  3. +++ b/src/Plugin/views/display_extender/LazyLoadDisplayExtender.php
    @@ -0,0 +1,180 @@
    +    if (FALSE && $this->isExcludedUserAgent()) {
    

    This will always return FALSE, needs fixing.

  4. +++ b/src/Plugin/views/display_extender/LazyLoadDisplayExtender.php
    @@ -0,0 +1,180 @@
    +    return $this->options['views_lazy_load_enabled'] && empty($_REQUEST['views_lazy_load_disabled']);
    

    We shouldn't use REQUEST, we should use \Drupal::request() or better yet, inject the service if possible here.

  5. +++ b/src/Plugin/views/display_extender/LazyLoadDisplayExtender.php
    @@ -0,0 +1,180 @@
    +    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    

    The current request can also be used here now, $request->headers->get->('User-Agent')

  6. +++ b/src/Plugin/views/display_extender/LazyLoadDisplayExtender.php
    @@ -0,0 +1,180 @@
    +        $form['#title'] .= $this->t('Enable Views Lazy Load');
    

    Is this meant to be concat, if so, do we need a space?

aguilarm’s picture

Requiring this module with composer for drupal 8 right now, fwiw, will require applying this patch before it works. The 8.x-1.x-dev in it's current state is still the d7 code.

gambry’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
FileSize
6.21 KB
26.45 KB

Attached a patch fixing feedback from #7.

Few notes:

  • +++ b/src/Plugin/views/display_extender/LazyLoadDisplayExtender.php
    @@ -0,0 +1,180 @@
    +        $form['#title'] .= $this->t('Enable Views Lazy Load');

    Is this meant to be concat, if so, do we need a space?

    This is the way most plugins do, see Block for example.

  • Excluded user agents are still fetched with views_lazy_load_get_excluded_user_agents() from .module, which now pulls data through the State API. Not sure if we like it for consistency, I would rather prefer to have the State service injected and called within the LazyLoadDisplayExtender plugin.
  • I have no idea what the unused $info = $this->displayHandler->getOption('empty'); is supposed to do. From the D7 code looks like we pass this option to the area->init() , but it is still needed for D8?

Test coverage is still missing.

gambry’s picture

Also the config schema definition for the plugin is missing and needs to be added.

Leaving Needs Review for community to give feedback on the notes, but this issue still Needs Work.

MustangGB’s picture

Just curious what this module gives you that BigPipe doesn't, or can't, for D8.

gambry’s picture

Big Pipe is in action where Page Cache isn't, so for example for authenticated users.

One example where this module may do something BigPipe can't is serving dynamic views to anonymous users when Page Cache (or something like Varnish) is ON.

MustangGB’s picture

Hmm okay, I haven't built any sites around this sort of thing in D8 yet so I don't really know what I'm talking about, but I thought Sessionless BigPipe was the solution to the anonymous user problem.

rahullamkhade’s picture

@MustangGB Do you know how to load view through Big Pipe?

admintauheed’s picture

Development version: 8.x-1.x-dev updated 16 Jan 2017 at 06:53 UTC

Hi can we use the above module on a live site

And is the patch applied

Thanks in advance

ravimane23’s picture

Applied the patch #9 manually in Drupal 8.9.

For Drupal 9, just minor change in info.yml file and the module will compatible with Drupal 9.

Added a new patch to make module compatible with D9.

bigmonmulgrew’s picture

Can we please get the dev version updated to reflect the patch.

If you like, add me as a maintainer and I'll add it myself.

generalredneck’s picture

Just want to throw this out there... You can use this in addition to something like Views Infinite Scroll (and a patch I threw over on #3202638: Lazy Load on Scroll) to do things like auto advancing articles or to defer loading large chunks of content until the user reaches it. This provides a user experience over just cloaking content from Search Engines or deferring load times.

lathan made their first commit to this issue’s fork.

nikathone made their first commit to this issue’s fork.

AndrewsizZ’s picture

Added patch for Drupal 10