Skip to content

Conversation

@AntoLC
Copy link
Collaborator

@AntoLC AntoLC commented Dec 22, 2025

How to Use

To use this feature, simply set the FRONTEND_JS_URL environment variable to the URL of your custom JavaScript file. For example:

FRONTEND_JS_URL=http://anything/custom-script.js

Once you've set this variable, our application will load your custom JavaScript file and execute it in the browser, allowing you to modify the application's behavior at runtime.

Benefits

This feature provides several benefits, including:

  • Dynamic customization 🔄: With this feature, you can dynamically modify the behavior and appearance of our application without requiring any code changes.
  • Flexibility 🌈: You can add custom functionality, modify existing features, or integrate third-party services.
  • Runtime injection ⏱️: This feature allows you to inject JavaScript into the application at runtime, without requiring a restart or recompilation.

Example Use Case

Let's say you want to add a custom menu to the application header. You can create a custom JavaScript file with the following contents:

(function() {
  'use strict';

  function initCustomMenu() {
    // Wait for the page to be fully loaded
    const header = document.querySelector('header');
    if (!header) return false;

    // Create and inject your custom menu
    const customMenu = document.createElement('div');
    customMenu.innerHTML = '<button>Custom Menu</button>';
    header.appendChild(customMenu);
    
    console.log('Custom menu added successfully');
    return true;
  }

  // Initialize when DOM is ready
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', initCustomMenu);
  } else {
    initCustomMenu();
  }
})();

Then, set the FRONTEND_JS_URL environment variable to the URL of your custom JavaScript file. Once you've done this, our application will load your custom JavaScript file and execute it, adding your custom menu to the header.

Demo

Here a custom menu created thanks to our custom js file: https://antolc.github.io/docs-customized/docs-custom/public/docs-custom.js

Enregistrement.2025-12-22.160438.mp4

@AntoLC AntoLC self-assigned this Dec 22, 2025
@AntoLC AntoLC added frontend feature add a new feature backend labels Dec 22, 2025
@AntoLC AntoLC linked an issue Dec 22, 2025 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Dec 22, 2025

Size Change: +108 B (0%)

Total Size: 4.15 MB

Filename Size Change
apps/impress/out/_next/static/151c1af4/_buildManifest.js 0 B -888 B (removed) 🏆
apps/impress/out/_next/static/chunks/4190.js 0 B -761 kB (removed) 🏆
apps/impress/out/_next/static/chunks/8343.js 761 kB +761 kB (new file) 🆕
apps/impress/out/_next/static/fa77cba6/_buildManifest.js 887 B +887 B (new file) 🆕

compressed-size-action

@AntoLC AntoLC force-pushed the feat/custom-js-setting branch from 73deeb7 to 277ee8f Compare December 22, 2025 14:58
From the config, we can add custom JS file URL
to be included in the frontend.
@AntoLC AntoLC force-pushed the feat/custom-js-setting branch from 277ee8f to a78ab93 Compare December 22, 2025 15:02
@AntoLC AntoLC requested review from lunika and rvveber December 22, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨Override Docs at runtime with js injection

2 participants