Skip to content

Load Json Render assets only when the module is used#35

Draft
sebastianthulin with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-assets-enqueued-on-all-pages
Draft

Load Json Render assets only when the module is used#35
sebastianthulin with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-assets-enqueued-on-all-pages

Conversation

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

Json Render assets were being registered from the app bootstrap, which loaded them on every page regardless of module usage. This change scopes frontend and admin assets to the module lifecycle so they are only added when the module is rendered or edited.

  • Stop global asset loading

    • Removed unconditional frontend/admin enqueue hooks from App
    • Keeps unrelated pages free of Json Render CSS/JS
  • Load frontend assets from the module

    • JsonRender::script() now enqueues the actual frontend bundle
    • JsonRender::style() now enqueues the frontend stylesheet
    • Frontend translations remain attached to the module script
  • Load admin assets only on the module edit screen

    • JsonRender::adminEnqueue() now enqueues the real admin bundle instead of the placeholder script
    • Admin CSS stays scoped to the module editor view
    • Existing options/translation payloads are preserved
  • Tighten enqueue configuration

    • Reused a shared dependency list for module JS assets
    • Left asset-loading behavior unchanged except for when assets are loaded
public function script()
{
    $this->wpEnqueue
        ?->add('js/Front/IndexFront.js', $this->getAssetDependencies())
        ->with()
        ->translation('modJsonRender', [
            'translation' => [
                'somethingWentWrong' => __('Something went wrong, please try again later.', 'modularity-json-render'),
            ],
        ]);
}

public function style()
{
    $this->wpEnqueue?->add('css/modularity-json-render-front.css');
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/carthage-software/mago/releases
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/zb3CNV /usr/bin/composer mago:install-binary --local git unit.git/' (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/IcVNyG /usr/bin/composer mago:install-binary git erator.git unit.git/' (http block)
  • https://api.github.com/repos/carthage-software/mago/zipball/9e1e3d1a4566349d3b07d1275bca53f3c93dabeb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/helsingborg-stad/acf-export-manager/zipball/9e1b282460cebf68ec4d83cd3c11d8fe7e3612fd
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/helsingborg-stad/wpservice/zipball/3ed37137b25defbc98e24904f8523ea2f86e3c24
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/helsingborg-stad/wputilservice/zipball/60afacdecc1aa72f14f135916bdffe80abd52dc0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/15c5dd40dc4f38794d383bb95465193f5e0ae180
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/183a9b2632194febd219bb9246eee421dad8d45e
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit/zipball/54391c61e4af8078e5b276ab082b6d3c54c9ad64
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/comparator/zipball/85c77556683e6eee4323e4c5468641ca0237e2e8
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/complexity/zipball/ee41d384ab1906c68852636b6de493846e13e5a0
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d36ad0d782e5756913e42ad87cb2890f4ffe467a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/c1ca3814734c07492b3d4c5f794f4b0995333da2
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3e0404dc6b300e6bf56415467ebcb3fe4f33e964
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3b415def83fbcb41f991d9ebf16ae4ad8b7837b3
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/75dfe79a2aa30085b7132bb84377c24062193f33
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JOQdFp /usr/bin/composer install --no-interaction --prefer-dist (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c
    • Triggering command: REDACTED, pid is -1 (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue May 13, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix assets enqueued on all pages Load Json Render assets only when the module is used May 13, 2026
Copilot AI requested a review from sebastianthulin May 13, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assets is enqueued on all pages

2 participants