Skip to main content
erikbongers
Participant
March 9, 2025
Question

Include another file into a .psjs script

  • March 9, 2025
  • 3 replies
  • 202 views

Hi,

Is it possible to include/require another file in a .psjs script?

I'm not talking about a plugin, but a stand-alone .psjs script.

If not, I believe this is possible with plugins?

Can I put a script in a plugin and use it without an UI interface, that is, use the plugin just like a script?

 

Thanks in advance,

Erik.

3 replies

Legend
March 9, 2025

UXP Script (psjs) can import external files in CommonJS format.

// main.psjs

const { alert } = require('./external.js') ;
alert('hello') ;
// external.js

const { app } = require('photoshop') ;

const alert = async (message) => {
  await app.showAlert(message) ;
} ;

module.exports = {
  alert
} ;

 

In UXP Plugin, you can develop a plugin without panel by specifying command in the entrypoints of manifest.json and not specifying panel.

creative explorer
Community Expert
Community Expert
March 9, 2025

@erikbongers Have you tried throught the Script Events Manager?

 

m
Inspiring
March 9, 2025

Non credo di aver capito bene la domanda.

 

Purtroppo la traduzione è un po' confusa.

 

Non puoi usare un'azione per chiamare il file psjs?

O vuoi un pannello con pulsanti che chiami il file psjs?

Se potessi essere più chiaro, sarò felice di aiutarti.