[[custom-javascript]]
= Custom JavaScript

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.



The Wicket viewer ships with embedded JQuery, so this can be leveraged, for example to perform arbitrary transformations of the rendered page on page load.

Similar to the xref:customisation.adoc#custom-css[application.css] file, the Wicket viewer automatically serves the `scripts/application.js` javascript file in every page load.
This is relative to the `static` package, under `src/main/resources`.
Currently only one such `.js` file can be registered.

If you wish to change the location of the file, use the xref:refguide:config:sections/causeway.viewer.wicket.adoc#causeway.viewer.wicket.application.js[causeway.viewer.wicket.application.js] configuration property.


[WARNING]
====
Just because something is possible, it doesn't necessarily mean we encourage it.
Please be aware that there is no formal API for any custom JavaScript that you might implement to target; future versions of Apache Causeway might break your code.

As an alternative, consider using the `ComponentFactory` API described in the xref:vw:ROOT:extending.adoc[extending] chapter.
====



