adding external js in gwt
gwt, java, javascript
Solution
To use this technique you have to place your `someJsFile.js` in your `public` folder so as the gwt compiler copy it to the final folder where it places the html and js stuff.
If you are using maven you have to check if the resources plugin is copying this file to the war and in which path.
By the way, there are other techniques to insert external javascript in your document:
Placing the script tag in your .html file.
Using ScriptInjector.fromUrl().
A better approach is to use a TextResource and `ScriptInjector.fromString()` so as the compiler reads the javascript file and includes the content in the final compiled file.
You can use gwtquery Ajax.getScript to get the script via ajax and inject it in the dom.
A new way, recently added to gwtquery, allows you to include your javascript as a JSNI block, so as the compiler can optimize and obfuscate it.
I'd rather the last one because it offers much more advantages.
Problem
I writed and checked my js code in GWT. For checking I added my js code in (projectName).html file and it is worked. But when I try added external js file I get an error: ``` WARN] 404 - GET <path to js file>someJsFile.js (127.0.0.1) 1452 bytes Request headers ``` I added this line to (projectName).gwt.xml file: ``` <script src="src/main/resources/<projectName>/someJsFile.js"></script> ```