[SalesForce] Where to store css when developing in salesforce

When having a custom style, would it be better to store them as static resource or just dump those styles inside Visualforce page as inline CSS?

  1. If putting them as static resource, what are the things need to be considered?
  2. If dumping them inside Visualforce page as inline CSS, what are the things need to be considered?

I'm guessing development in Salesforce is different from other development.

Best Answer

There is no 'proper' way to do this, but typically the resources will end up in a static resource so that's a good way to go, although it can be rather painful to constantly zip up files and upload them. Resource bundles in MavensMate can make this setup far easier to deal with: you can edit a file and upload with a zip with a couple of keystrokes. I highly recommend this approach as it means you'll be using your intended file structure etc. within the zip file, something you'll need to consider when you're using bundled images/Javascript as well.

An alternative, and handy option, during development is to use a cloud storage service like Dropbox. Put your CSS in the public folder, get a public link and then use that inside of your page to include the CSS. That way you can just hit save on the file, wait a couple of seconds and then refresh your Visualforce page to see the result. In my experience it takes no more than two to three seconds for Dropbox to sync small files like that. See the link: Productivity Tip : Quicker Javascript and CSS development using Dropbox

Related Topic