Enable ajax loader on specific pages

Created on 21 June 2019, over 5 years ago
Updated 2 August 2023, over 1 year ago

It would be great if we have an option to enable the ajax loading on specific pages like how block configurations work.

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇵🇭Philippines montesajudy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • @imalabya opened merge request.
  • 🇮🇳India imalabya Bangalore

    Updated the patch to fix path_alias.manager.

  • 🇮🇳India imalabya Bangalore

    The patch didn't address the wildcard entries in the pages. Adding a patch to fix that.

  • 🇺🇸United States kentr

    @imalabya: I'm getting an undefined variable warning after applying the patch.

    Warning: Undefined variable $match in ajax_loader_page_attachments() (line 81 of modules/contrib/ajax_loader/ajax_loader.module).

    I don't see current Drupal standards on undefined variables, but I think eliminating them is helpful if for no other reason than to help more critical errors stand out more.

    Adding $match = FALSE; ~ line 57 removes the error.

    @mvogel:

    I am not sure that enabling ajax loader only on specific pages is a real use case

    For me, the use case is keeping ajax loader from loading assets on pages that don't need them. With the current ajax loader functionality, I see the assets / libraries loading on all pages, regardless of whether they have any ajax functionality.

    There may be a better way than this change to restrict the loader to only the pages that need it, though.

  • 🇧🇪Belgium rgeerolf Belgium 🇧🇪🇪🇺
  • 🇺🇸United States devkinetic

    Coming back to this, I don't disagree that the current implementation of only loading on specific pages is incorrect, and it does make the configuration more needlessly complex. I do feel that the premise is still valid though. The way JS in Drupal works normally is that assets are only added to the page when they are specifically needed, and it should happen dynamically.

    I think that a new implementation should be planned out, whatever that may actually be. Currently, the assets are added to pages that do not require it.

Production build 0.71.5 2024