- Jan 30, 2015
- by Brad Litwin
Encapsulate your code. Don’t just put a script tag on your page and start writing code in it. Put it inside of a new function and then call that function within a document ready function. Isolate your code from any other code that may be running on your page. This will help prevent your code from breaking other scripts you want to include on the page. Even from multiple scripts of your own conflicting with each other.