Including javascript with plugin

I’m a little confused about how to include javascript alongside plugin functions. If I do this:


function myPluginFunction() {




it doesn’t work. This error comes up in the console:

scripts.js:1 Uncaught SyntaxError: Unexpected token <

and when I look at the resource in Dev Tools, it looks like this:

<script src=""></script>console.log('success!')

I could always just load these scripts in my templates, but in this case I need to add a small bit of JS functionality to the panel.

What’s up?

Looks like your script is parsed outside the scoop.

I use it like this;


class MyField extends TextField {

  static public $assets = array(
    'js' => array(

  public function content() {

  public function input() {


- edit - Nevermind, this is the code for a field, not a plug-in. (still your code is rendered outside the scoop, 'though).

You can’t currently load JS into the Panel from a plugin, only from a field.