Skip to content

ModuleJS::init() not loading CSS/JS assets (regression from #2175 fix) #2181

@tiefenb

Description

@tiefenb

Short description of the issue

ModuleJS::init() no longer loads module CSS/JS assets after commit 3653a70 (fix for #2175).
The refactored code collects asset URLs into an array but never registers them with $config->styles or $config->scripts.

Expected behavior

Modules extending ModuleJS (like JqueryWireTabs, LanguageTabs, etc.) should have their CSS and JS files automatically loaded when the module is instantiated via $modules->get().

Actual behavior

CSS and JS files for ModuleJS-based modules are not loaded, causing JavaScript errors throughout the admin:

Uncaught TypeError: $(...).WireTabs is not a function
at HTMLDocument. (ProcessModule.js:27:28)

Uncaught TypeError: $(...).WireTabs is not a function
at initPageEditForm (ProcessPageEdit.js:4:57)

Screenshots/Links that demonstrate the issue

Network tab shows JqueryWireTabs.js is missing from loaded scripts.
Console shows the TypeError above on any page using tabs (Modules, Page Edit, etc.).

Suggestion for a possible fix

In wire/core/ModuleJS.php, the second foreach loop (around line 136) collects URLs but doesn't add them. Replace:

foreach($assets as $basename) {
$file = $modulePath . $basename;
$fileUrl = $moduleUrl . $basename;
if($useVersionUrls === null) {
if($debug) $version = filemtime($file);
$fileUrl .= "?v=$version";
}
$assetUrls[] = $fileUrl;
}

With:

foreach($assets as $key => $basename) {
$file = $modulePath . $basename;
$fileUrl = $moduleUrl . $basename;
if($useVersionUrls === null) {
if($debug) $version = filemtime($file);
$fileUrl .= "?v=$version";
}
if($key === 'css') {
if($this->loadStyles) $config->styles->add($fileUrl);
} else {
if($this->loadScripts) $config->scripts->add($fileUrl);
}
}

Steps to reproduce the issue

  1. Update to ProcessWire dev branch (commit 3653a70 or later, version 3.0.255)
  2. Open any admin page using WireTabs (e.g., /processwire/module/ or /processwire/page/edit/?id=1)
  3. Open browser DevTools Console
  4. Observe "WireTabs is not a function" error
  5. Check Network tab - confirm JqueryWireTabs.js is not loaded

Setup/Environment

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