Comex (the creator of Spirit ) has released browser based jailbreak for iOS 4.0 and iOS 4.0.1
this time is the easiest it is done from the iPhone itself
then slide the the button to jailbreak
If you have issue in installing it like you stuck with the purple screen please use the below steps.
Step 1: Navigate to Settings –> Safari and then clear out History, Cookies and Cache.
Step 2: Reboot your iOS device by turning it off, and then back on.
Step 3: Now try http://jailbreakme.com or http://jailbreakme.modmyi.com again.