8

Are there any good tricks for debugging/developing on Salesforce when I have multiple external Javascript files that have to be saved and uploaded as Static Resources every time I make a change? It's incredibly slow this way.

The only workaround I've been able to stand is putting the Javascript inline in the HTML- but of course I get no syntax highlighting at all that way. It's like I'm coding in 1995.

Any tricks or tips for coding fast when using externally referenced files such as Javascript or CSS?

Many thanks!

5

Easy! As long as you're using eclipse. If the static resources are text files you can edit them directly. If the static resources are in a zip file you'll want to install the Eclipse Zip Editor Plugin which will let you edit files inside the zip file easily.

| improve this answer | |
  • Thanks Ralph- I had never heard of that. Sounds like a godsend. I will try it out today. I'm on a Mac, so I'm not sure if the Force.com IDE will support it (I think it's just an Eclipse branch). – Hairgami_Master May 7 '13 at 13:15
  • I'm on a mac. If you downloaded the stand alone Force.com IDE I don't think you can add plugins though. Fortunately, I'll you'll need to do is download eclipse and install the Force.com IDE as a plugin (instead of the standalone). The Salesforce installation page has instructions for both ways. – Ralph Callaway May 7 '13 at 20:13
  • I'm going to give that a shot, though I think our Git repositories will not merge properly this way. – Hairgami_Master May 8 '13 at 13:12
  • Lol, one problem at a time. In any event, just don't zip it if you want the repo to compare correctly. It'll be faster to edit them as individual files, they'll compare, and the performance hit to the end user by not zipping is probably pretty negligible (YMMV) unless you have a really massive js library your buildling. – Ralph Callaway May 8 '13 at 16:02
2

Usually I create a visualforce component for the development with javascript inside and when it is consolidated I move it in static resource.

I know that isn't the best but make the development faster.

| improve this answer | |
  • Thanks Alberto for the suggestion- I'll give it a shot, see how it works. At least I could open that component in another editor with code highlighting. – Hairgami_Master May 6 '13 at 16:53
2

I definitely agree with Buyan that using the hybrid approach is far better than constant uploading of JS files to static resource. You can also invoke logging using the following:

sforce.debug.log(myVar);

I find this really helpful when debugging JS. Also, you can open the debugging window at any time using:

sforce.debug.open();

I hope everything works out for you! Goodluck :)

| improve this answer | |
  • Many thanks man. Didn't know about the sforce.debug object. Will definitely give that a shot. – Hairgami_Master May 6 '13 at 18:40
  • No worries. Let me know how that goes :) – subodhbahl May 6 '13 at 18:42
1

I would recommend a hybrid approach. Divide your javascripts into 2 parts. The ones you change less should be confined to one visual force component and plugged in to your vfpage. If you have javascripts which you are constantly debugging, why dont you use active function and do debugging on system.debug rather than use javascript? Using the ajax library in built would help to cut down debugging time a lot. Thanks Buyan

| improve this answer | |
  • Thanks buyan for the suggestion. I'm going to give that a shot. – Hairgami_Master May 6 '13 at 16:56
1

I generally start with inline JavaScript. If you find this a pain too (which it is), there are a number of browser plugins that allow you to add and manipulate JS in a web page which may meet your needs but I'm no expert with those. Even just Chrome developer tools give you the ability to edit page code, which sometimes helps with basic bugs (especially HTML/DOM-related) faster than SF.

Once my inline JS is working, I move it out to local text files, where I run an ant job that bundles all my static resources together, does JS minification, and uploads them as a static resource using the Force.com Migration Toolkit.

If I'm doing a JS bugfix, I'll usually move the externalized code back into the VF page while I debug.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.