Skip to content

Add attributes to script tags in admin theme. #468

@elabx

Description

@elabx

Short description of the enhancement

Be able to add attributes to script tags in admin theme.

Optional: Steps that explain the enhancement

Hi @ryancramerdesign !

Recently had a conversation with a couple forum members on the topic of being able to add attributes to script tags. This issue came about when talking about using Alpine.js for the development of a ProcessWire Inputfield, and the requirement of Alpine to be installed with the deferred attribute.

I am not sure is this is the right approach to make the tags output configurable but nonetheless decided to give it a shot, as one of the forum members (kongondo) proposed.

processwire/processwire#250

So in the Inputfield modules we could do something like:

public function renderReady(Inputfield $parent = null, $renderValueMode = false){
  $this->config->scripts->add("https://unpkg.com/alpinejs@3.10.2/dist/cdn.min.js", 
    ['defer' => true] 
  );
  parent::renderReady($parent, $renderValueMode);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions